Skip to content

Commit 08fdb92

Browse files
Masaya Nasukazupon
Masaya Nasu
authored andcommitted
Translate Japanese (#541)
* Translate Japanese * add japanese doc link * translate for README.md with japanese * translate for spec.md with japanese * translate for setup.md with japanese * translate for es2015.md with japanese * translate for scoped-css.md with japanese * translate for css-modules.md with japanese * translate for postcss.md with japanese * translate for hot-reload.md with japanese * translate for pre-processors.md with japanese * translate for asset-url.md with japanese * translate for advanced.md with japanese * translate for extract-css.md with japanese * translate for production.md with japanese * translate for linting.md with japanese * translate for testing.md with japanese * translate for testing-with-mocks.md with japanese * translate for options.md with japanese * fix typo and check style README.md * fix typo and check style spec.md * add custom-blocks.md * fix typo and check style es2015.md * fix typo and check style scoped-css.md * rewrite advanced.md * fix README.md * translate for SUMMARY.md * fix asset-url.md * fix typo pre-processors.md * fix typo hot-reload.md * fix tone production.md * fix css-modules.md * fix es2015.md * fix es2015.md * fix postcss.md * fix scoped-css.md * fix options.md * fix options.md * fix setup.md * fix spec.md * fix lint.md * fix testing-with-mocks.md * fix testing.md * translate for custom-blocks.md with japanese * check and fix
1 parent bded451 commit 08fdb92

20 files changed

+1293
-1
lines changed

docs/LANGS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* [English](en/)
22
* [한국어](kr/)
33
* [Русский](ru/)
4-
* [Português](pt_BR/)
4+
* [Português](pt_BR/)
5+
* [日本語](ja/)

docs/ja/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# はじめに
2+
3+
### `vue-loader` とは ?
4+
5+
`vue-loader` とは以下の形式で記述された Vue コンポーネントをプレーンな JavaScript モジュールに変換する Webpack の loader です。
6+
7+
![screenshot](http://blog.evanyou.me/images/vue-component.png)
8+
9+
`vue-loader` によって多くのクールな機能が提供されます:
10+
11+
- デフォルトで ES2015 が有効;
12+
- `<style>` には SASS、 `<template>` には Jade など、Vue コンポーネントの各パーツに他の Webpack の loader が使用可能;
13+
カスタム loader チェーンを適用できる .vue ファイルのカスタムセクションを追加可能;
14+
- `<style>``<template>` で参照される静的なアセットをモジュールの依存として扱い、Webpack の loader で処理可能;
15+
- 各コンポーネントで scoped CSS をシミュレートすることが可能;
16+
- 開発時のコンポーネントのホットリロードをサポート
17+
18+
つまり、Webpack と `vue-loader` の組み合わせは Vue.js アプリケーションを作成するための、現代的で柔軟かつとても強力なフロントエンドワークフローを実現することが可能になります。
19+
20+
### Webpack とは?
21+
22+
すでに Webpack に精通している場合は、次の説明を省略してもかまいません。しかし、Webpack を初めて使う人のために、ここで簡単な紹介を行います。
23+
24+
[Webpack](http://webpack.github.io/) とはモジュールのバンドラーです。それぞれのファイルをモジュールとして扱い、それらの間の依存関係を解決し、デプロイの準備が整った静的アセットにバンドルします。
25+
26+
![webpack](http://webpack.github.io/assets/what-is-webpack.png)
27+
28+
基本的な例として、CommonJS モジュールが多数あるとします。これらはブラウザで直接実行できません。なのでそれらを `<script>` タグを介して読み込むことのできる単一のファイルに "バンドル" する必要があります。Webpack は `require()` での依存性解決と実行を行うことが出来ます。
29+
30+
しかし Webpack はそれ以上のことが出来ます。 "loader" を用いることで、最終的なバンドルしたファイルを出力する前に Webpack に様々な方法で全てのタイプのファイルを変換できるように設定することが出来ます。いくつかの例をあげると:
31+
32+
- ES2015、CoffeeScript、TypeScript のモジュールをプレーンな ES5 の CommonJS モジュールにトランスパイル;
33+
- オプションでコンパイルを行う前にソースコードを linter に通すことが可能;
34+
- Jade テンプレートをプレーンな HTML にトランスパイルし、JavaScript の文字列として展開;
35+
- SASS ファイルをプレーンな CSS にトランスパイルし、`<style>` タグとして挿入する JavaScript スニペットに変換;
36+
- HTML または CSS で参照されるイメージファイルを処理し、パスの設定に基づいた目的の場所に移動し、md5 ハッシュを使用して名前付け;
37+
38+
Webpack は非常に強力です。どのように動作するか理解すれば、フロントエンド開発のワークフローを劇的に向上させることが出来ます。欠点としては冗長で複雑な構成です。しかし、このガイドでは Vue.js と `vue-loader` での Webpack を使用する際に一般的な問題の解決策を見つけることができるはずです。

docs/ja/SUMMARY.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
- 入門
2+
- [Vue Component の仕様](start/spec.md)
3+
- [プロジェクトのセットアップ](start/setup.md)
4+
- 機能
5+
- [ES2015](features/es2015.md)
6+
- [スコープ付き CSS](features/scoped-css.md)
7+
- [CSS モジュール](features/css-modules.md)
8+
- [PostCSS](features/postcss.md)
9+
- [ホットリロード](features/hot-reload.md)
10+
- 構成
11+
- [プリプロセッサの使用](configurations/pre-processors.md)
12+
- [アセット URL ハンドリング](configurations/asset-url.md)
13+
- [高度な loader の設定](configurations/advanced.md)
14+
- [CSS を単一のファイルに抽出する](configurations/extract-css.md)
15+
- [カスタムブロック](configurations/custom-blocks.md)
16+
- ワークフロー
17+
- [プロダクションビルド](workflow/production.md)
18+
- [Linting](workflow/linting.md)
19+
- [テスト](workflow/testing.md)
20+
- [モックを使用したテスト](workflow/testing-with-mocks.md)
21+
- [オプションリファレンス](options.md)

docs/ja/configurations/advanced.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# 高度な loader の設定
2+
3+
時折こうしたくなるかもしれません:
4+
5+
1. `vue-loader` が推測するのではなく、カスタム loader の文字列を言語に適用する。
6+
2. デフォルトの言語の組み込み loader の設定の上書き。
7+
3. 特定の言語ブロックをカスタム loader で前処理か後処理をする。
8+
9+
そうするためには、`vue-loader``loaders` オプションを指定してください:
10+
11+
> メモ: `preLoaders``postLoaders` は 10.3.0 以上でのみサポートされます
12+
13+
### Webpack 2.x
14+
15+
``` js
16+
module.exports = {
17+
// 他のオプション
18+
module: {
19+
// module.rules は 1.x での module.loaders と同じです
20+
rules: [
21+
{
22+
test: /\.vue$/,
23+
loader: 'vue-loader',
24+
options: {
25+
// `loaders` はデフォルトの loaderを上書きします。
26+
// 次の設定では、"lang" 属性のない全ての <script> タグに
27+
// coffee-loader が適用されます。
28+
loaders: {
29+
js: 'coffee-loader'
30+
},
31+
32+
// `preLoaders` はデフォルトの loader の前に付加されます。
33+
// これを使用して言語ブロックを前処理することができます。
34+
// 一般的な使用例はビルドタイム i18n です。
35+
preLoaders: {
36+
js: '/path/to/custom/loader'
37+
},
38+
39+
// `postLoaders` はデフォルトの loader の後につけられます。
40+
//
41+
// - `html` の場合、デフォルトの loader によって返される結果は、
42+
// コンパイルされた JavaScript レンダリング関数コードになります。
43+
//
44+
// - `css` の場合、結果は vue-style-loader によって返されます。
45+
// しかしこれはほとんどの場合特に有用ではありません。
46+
// postcss プラグインを使用する方が良い選択になります。
47+
postLoaders: {
48+
html: 'babel-loader'
49+
}
50+
}
51+
}
52+
]
53+
}
54+
}
55+
```
56+
57+
### Webpack 1.x
58+
59+
``` js
60+
// webpack.config.js
61+
module.exports = {
62+
// ほかのオプション
63+
module: {
64+
loaders: [
65+
{
66+
test: /\.vue$/,
67+
loader: 'vue'
68+
}
69+
]
70+
},
71+
// vue-loader の設定
72+
vue: {
73+
loaders: {
74+
// 上記の設定と同じ
75+
}
76+
}
77+
}
78+
```
79+
80+
高度な loader の設定のより実用的な使用方法は、[CSS を単一のファイルに抽出する](./expression-css.md)にあります。

docs/ja/configurations/asset-url.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# アセット URL ハンドリング
2+
3+
デフォルトで `vue-loader`[css-loader](https://github.com/webpack/css-loader) と Vue テンプレートコンパイラーでスタイルとテンプレートファイルは自動で処理されます。このコンパイル処理中で全ての `<img src="...">``background: url(...)` や CSS の `@import` のようなアセットの URL は **モジュールの依存関係として処理されます**
4+
5+
例えば、`url(./image.png)``require('./image.png')` に変換され、そして
6+
7+
``` html
8+
<img src="../image.png">
9+
```
10+
11+
このようにコンパイルされます:
12+
13+
``` js
14+
createElement('img', { attrs: { src: require('../image.png') }})
15+
```
16+
もちろん `.png` ファイルは JavaScript のファイルではありません。[file-loader](https://github.com/webpack/file-loader) または [url-loader](https://github.com/webpack/url-loader) を使用して Webpack を設定する必要があります。`vue-cli` でスキャフォールドされたプロジェクトでは同じような設定がなされています。
17+
18+
利点の全ては次の通りです:
19+
20+
1. `file-loader` はアセットファイルのコピー先や配置先を制定したり、バージョンハッシュを利用してキャッシングを改善する方法を指定する事が出来ます。さらに、これは、単に**あなたの `* .vue` ファイルの隣にイメージを置くことができ、配備するURLを心配するのではなくフォルダ構造に基づいて相対パスを使用する**ことを意味します。
21+
22+
2. `url-loader` は、指定されたしきい値よりも小さい場合、条件付きでファイルを base-64 データ URL としてインライン化することができます。これにより、単純なファイルに対する HTTP リクエストの量を減らすことができます。 ファイルがしきい値より大きい場合、自動的に `file-loader` にフォールバックします。
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# カスタムブロック
2+
3+
> 10.2.0 以上で動作します
4+
5+
`*.vue` ファイル内にカスタム言語ブロックを定義することが出来ます。カスタムブロックの内容は `vue-loader` のオブジェクトで指定された loader によって処理され、次にコンポーネントモジュールによって要求されます。この設定は `lang` 属性の代わりにタグ名を使用する点をのぞいて[高度な loader の設定](../configurations/advanced.md)に記載されたものと似ています。
6+
7+
もしカスタムブロックにマッチする loader を見つけたら、それは処理されます。でなければそのカスタムブロックは単に無視されます。
8+
9+
##
10+
11+
全ての `<docs>` カスタムブロックを一つのドキュメントファイルに展開する例を示します:
12+
13+
#### component.vue
14+
15+
``` html
16+
<docs>
17+
## これは example component です
18+
</docs>
19+
20+
<template>
21+
<h2 class="red">{{msg}}</h2>
22+
</template>
23+
24+
<script>
25+
export default {
26+
data () {
27+
return {
28+
msg: 'Hello from Component A!'
29+
}
30+
}
31+
}
32+
</script>
33+
34+
<style>
35+
comp-a h2 {
36+
color: #f00;
37+
}
38+
</style>
39+
```
40+
41+
#### webpack.config.js
42+
43+
``` js
44+
// Webpack 2.x
45+
var ExtractTextPlugin = require("extract-text-webpack-plugin")
46+
47+
module.exports = {
48+
module: {
49+
rules: [
50+
{
51+
test: /\.vue$/,
52+
loader: 'vue',
53+
options: {
54+
loaders: {
55+
// 全ての <docs> の内容は raw text として展開されます
56+
'docs': ExtractTextPlugin.extract('raw-loader'),
57+
}
58+
}
59+
}
60+
]
61+
},
62+
plugins: [
63+
// 全ての docs は一つのファイルに出力されます
64+
new ExtractTextPlugin('docs.md')
65+
]
66+
}
67+
```

docs/ja/configurations/extract-css.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# CSS を単一のファイルに抽出する
2+
3+
すべての Vue コンポーネントで処理されたすべての CSS を1つの CSS ファイルに抽出する例:
4+
5+
### Webpack 2.x
6+
7+
``` bash
8+
npm install extract-text-webpack-plugin@2.x --save-dev
9+
```
10+
11+
``` js
12+
// webpack.config.js
13+
var ExtractTextPlugin = require("extract-text-webpack-plugin")
14+
15+
module.exports = {
16+
// 他の設定
17+
module: {
18+
rules: [
19+
{
20+
test: /\.vue$/,
21+
loader: 'vue-loader',
22+
options: {
23+
loaders: {
24+
css: ExtractTextPlugin.extract({
25+
use: 'css-loader',
26+
fallback: 'vue-style-loader' // <- これは vue-loader の依存ですので、npm3 を使用している場合は明示的にインストールする必要はありません
27+
})
28+
}
29+
}
30+
}
31+
]
32+
},
33+
plugins: [
34+
new ExtractTextPlugin("style.css")
35+
]
36+
}
37+
```
38+
39+
### Webpack 1.x
40+
41+
``` bash
42+
npm install extract-text-webpack-plugin --save-dev
43+
```
44+
45+
``` js
46+
// webpack.config.js
47+
var ExtractTextPlugin = require("extract-text-webpack-plugin")
48+
49+
module.exports = {
50+
// 他の設定
51+
module: {
52+
loaders: [
53+
{
54+
test: /\.vue$/,
55+
loader: 'vue'
56+
},
57+
]
58+
},
59+
vue: {
60+
loaders: {
61+
css: ExtractTextPlugin.extract("css"),
62+
// <style lang="less"> または他の言語も含めることができます
63+
less: ExtractTextPlugin.extract("css!less")
64+
}
65+
},
66+
plugins: [
67+
new ExtractTextPlugin("style.css")
68+
]
69+
}
70+
```
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# プリプロセッサの使用
2+
3+
Webpack において、全てのプリプロセッサは対応する loader を適用する必要があります。 `vue-loader` は他の Webpack の loader を使って Vue コンポーネントを処理することが出来ます。言語ブロックの `lang` 属性から適切な loader を自動的に推論します。
4+
5+
### CSS
6+
7+
例えば、SASS で `<style>` タグをコンパイルしましょう:
8+
9+
``` bash
10+
npm install sass-loader node-sass --save-dev
11+
```
12+
13+
``` html
14+
<style lang="sass">
15+
/* ここにSASSを書きます */
16+
</style>
17+
```
18+
19+
`<style>` タグ内のテキストコンテンツは、`sass-loader` によって最初にコンパイルされ、その後の処理のために渡されます。
20+
21+
#### sass-loader 使用時の注意
22+
23+
その名前が示すものとは対照的に、[* sass * -loader](https://github.com/jtangelder/sass-loader) はデフォルトで *SCSS* の構文を解析します。インデントされた *SASS* 構文を実際に使用する場合は、それに応じて sass-loader へ vue-loader のオプションを設定する必要があります。
24+
25+
```javascript
26+
{
27+
test: /\.vue$/,
28+
loader: 'vue-loader',
29+
options: {
30+
loaders: {
31+
scss: 'vue-style-loader!css-loader!sass-loader' // <style lang="scss">
32+
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax' // <style lang="sass">
33+
}
34+
}
35+
}
36+
```
37+
38+
vue-loader を構成する方法の詳細については、[高度な loader の設定](./advanced.md)セクションを参照してください。
39+
40+
### JavaScript
41+
42+
全てのVueコンポーネントのJavaScriptはデフォルトで `babel-loader` によって処理されます。しかしもちろんそれは変更することが可能です:
43+
44+
``` bash
45+
npm install coffee-loader --save-dev
46+
```
47+
48+
``` html
49+
<script lang="coffee">
50+
# coffeescript を書いてください!
51+
</script>
52+
```
53+
54+
### テンプレート
55+
56+
`pug-loader` のようなほとんどのWebpackテンプレート loader は、コンパイルされたHTML文字列の代わりにテンプレート関数を返すので、template の処理は少し異なります。`pug-loader` を使う代わりに、オリジナルの `pug` をインストールをするだけです:
57+
58+
``` bash
59+
npm install pug --save-dev
60+
```
61+
62+
``` html
63+
<template lang="pug">
64+
div
65+
h1 Hello world!
66+
</template>
67+
```
68+
69+
> **重要:** もし `vue-loader@<8.2.0` を使うのであれば、`template-html-loader` が必要になります。
70+
71+
### インラインローダーリクエスト
72+
73+
`lang` 属性で [Webpack loader requests](https://webpack.github.io/docs/loaders.html#introduction) を使用することが可能です:
74+
75+
``` html
76+
<style lang="sass?outputStyle=expanded">
77+
/* ここでは拡張出力で sass を使用します */
78+
</style>
79+
```
80+
81+
ただこれにより Vue コンポーネントが Webpack 固有となり Browserify および [vueify](https://github.com/vuejs/vueify) と互換性がなくなります。 **Vue コンポーネントを再利用可能なサードパーティコンポーネントとして提供する場合は、この構文を使用しないでください。**

0 commit comments

Comments
 (0)