Skip to content

Commit d7b0c80

Browse files
authored
Merge pull request #1 from vuejs/master
merge with upstream
2 parents d542d84 + eea5c17 commit d7b0c80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+9931
-4914
lines changed

docs/book.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "vue-loader",
33
"gitbook": ">3.0.0",
4-
"plugins": ["edit-link", "theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git", "-fontsettings", "github"],
4+
"plugins": ["edit-link", "theme-vuejs", "-fontsettings", "github"],
55
"pluginsConfig": {
66
"edit-link": {
77
"base": "https://github.com/vuejs/vue-loader/tree/master/docs",

docs/en/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ In a nutshell, the combination of Webpack and `vue-loader` gives you a modern, f
2121

2222
If you are already familiar with Webpack, feel free to skip the following explanation. But for those of you who are new to Webpack, here's a quick intro:
2323

24-
[Webpack](http://webpack.github.io/) is a module bundler. It takes a bunch of files, treating each as a module, figuring out the dependencies between them, and bundle them into static assets that are ready for deployment.
24+
[Webpack](https://webpack.github.io/) is a module bundler. It takes a bunch of files, treating each as a module, figuring out the dependencies between them, and bundle them into static assets that are ready for deployment.
2525

26-
![webpack](http://webpack.github.io/assets/what-is-webpack.png)
26+
![webpack](https://webpack.github.io/assets/what-is-webpack.png)
2727

2828
For a basic example, imagine we have a bunch of CommonJS modules. They cannot run directly inside the browser, so we need to "bundle" them into a single file that can be included via a `<script>` tag. Webpack can follow the dependencies of the `require()` calls and do that for us.
2929

docs/en/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
- [cssSourceMap](options.md#csssourcemap)
2727
- [esModule](options.md#esmodule)
2828
- [preserveWhitespace](options.md#preservewhitespace)
29+
- [compilerModules](options.md#compilermodules)
30+
- [compilerDirectives](options.md#compilerdirectives)
2931
- [transformToRequire](options.md#transformtorequire)
3032
- [buble](options.md#buble)
3133
- [extractCSS](options.md#extractcss)

docs/en/configurations/pre-processors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Then add the following webpack rule:
5656
}
5757
```
5858

59-
As an example, if you are using [vuejs-templates/webpack](https://github.com/vuejs-templates/webpack), modify `build/util.js` like so:
59+
As an example, if you are using [vuejs-templates/webpack](https://github.com/vuejs-templates/webpack), modify `build/utils.js` like so:
6060

6161
``` js
6262
scss: generateLoaders('sass').concat(

docs/en/features/hot-reload.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,18 @@
44

55
![hot-reload](http://blog.evanyou.me/images/vue-hot.gif)
66

7+
## State Preservation Rules
8+
9+
- When editing the `<template>` of a component, instances of the edited component will re-render in place, preserving all current private state. This is possible because templates are compiled into new render functions that produce no side-effects.
10+
11+
- When editing the `<script>` part of a component, instances of the edited component will be destroyed and re-created in place. (State of the other components in the app are preserved) This is because `<script>` can include lifecycle hooks that may produce side-effects, so a "reload" instead of re-render is required to ensure consistent behavior. This also means you need to be careful about global side effects such as timers inside your components lifecycle hooks. Sometimes you may need to do a full-page reload if your component produces global side-effects.
12+
13+
- `<style>` hot reload operates on its own via `vue-style-loader`, so it doesn't affect application state.
14+
15+
## Usage
16+
717
When scaffolding the project with `vue-cli`, Hot Reload is enabled out-of-the-box.
18+
19+
When manually setting up your project, hot-reload is enabled automatically when you serve your project with `webpack-dev-server --hot`.
20+
21+
Advanced users may want to check out [vue-hot-reload-api](https://github.com/vuejs/vue-hot-reload-api), which is used internally by `vue-loader`.

docs/en/features/scoped-css.md

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,50 @@ Into the following:
2828
</template>
2929
```
3030

31-
#### Notes
31+
## Tips
3232

33-
1. You can include both scoped and non-scoped styles in the same component:
33+
### Mixing Local and Global Styles
3434

35-
``` html
36-
<style>
37-
/* global styles */
38-
</style>
35+
You can include both scoped and non-scoped styles in the same component:
3936

40-
<style scoped>
41-
/* local styles */
42-
</style>
43-
```
37+
``` html
38+
<style>
39+
/* global styles */
40+
</style>
41+
42+
<style scoped>
43+
/* local styles */
44+
</style>
45+
```
46+
47+
### Child Component Root Elements
48+
49+
With `scoped`, the parent component's styles will not leak into child components. However, a child component's root node will be affected by both the parent's scoped CSS and the child's scoped CSS. This is by design so that the parent can style the child root element for layout purposes.
50+
51+
### Deep Selectors
52+
53+
If you want a selector in `scoped` styles to be "deep", i.e. affecting child components, you can use the `>>>` combinator:
54+
55+
``` html
56+
<style scoped>
57+
.a >>> .b { /* ... */ }
58+
</style>
59+
```
60+
61+
The above will be compiled into:
62+
63+
``` css
64+
.a[data-v-f3f3eg9] .b { /* ... */ }
65+
```
4466

45-
2. A child component's root node will be affected by both the parent's scoped CSS and the child's scoped CSS.
67+
Some pre-processors, such as SASS, may not be able to parse `>>>` properly. In those cases you can use the `/deep/` combinator instead - it's an alias for `>>>` and works exactly the same.
4668

47-
3. Partials are not affected by scoped styles.
69+
### Dynamically Generated Content
4870

49-
4. **Scoped styles do not eliminate the need for classes**. Due to the way browsers render various CSS selectors, `p { color: red }` will be many times slower when scoped (i.e. when combined with an attribute selector). If you use classes or ids instead, such as in `.example { color: red }`, then you virtually eliminate that performance hit. [Here's a playground](http://stevesouders.com/efws/css-selectors/csscreate.php) where you can test the differences yourself.
71+
DOM content created with `v-html` are not affected by scoped styles, but you can still style them using deep selectors.
5072

51-
5. **Be careful with descendant selectors in recursive components!** For a CSS rule with the selector `.a .b`, if the element that matches `.a` contains a recursive child component, then all `.b` in that child component will be matched by the rule.
73+
### Also Keep in Mind
5274

53-
6. If you need nested selectors in `scoped` styles, you will have to use `>>>` operator for CSS and `/deep/` for `scss`:
75+
- **Scoped styles do not eliminate the need for classes**. Due to the way browsers render various CSS selectors, `p { color: red }` will be many times slower when scoped (i.e. when combined with an attribute selector). If you use classes or ids instead, such as in `.example { color: red }`, then you virtually eliminate that performance hit. [Here's a playground](https://stevesouders.com/efws/css-selectors/csscreate.php) where you can test the differences yourself.
5476

55-
``` html
56-
<style scoped>
57-
.a >>> .b {
58-
59-
}
60-
</style>
61-
62-
<style lang="scss" scoped>
63-
.a /deep/ .b {
64-
65-
}
66-
</style>
67-
```
77+
- **Be careful with descendant selectors in recursive components!** For a CSS rule with the selector `.a .b`, if the element that matches `.a` contains a recursive child component, then all `.b` in that child component will be matched by the rule.

docs/en/options.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ module.exports = {
137137

138138
If set to `false`, the whitespaces between HTML tags in templates will be ignored.
139139

140+
### compilerModules
141+
142+
- type: `Array<ModuleOptions>`
143+
- default: `[]`
144+
145+
Configure `modules` options for `vue-template-compiler`. In about details, see more [`modules` option](https://github.com/vuejs/vue/blob/dev/packages/vue-template-compiler/README.md#compilercompiletemplate-options) of `vue-template-compiler`.
146+
147+
### compilerDirectives
148+
149+
- type: `{ [tag: string]: Function }`
150+
- default: `{}` (v13.0.5+)
151+
152+
> version note: in v12.x, supported in v12.2.3+
153+
154+
Configure `directives` options for `vue-template-compiler`, In about details, see more [`directives` option](https://github.com/vuejs/vue/blob/dev/packages/vue-template-compiler/README.md#compilercompiletemplate-options) of `vue-template-compiler`.
155+
140156
### transformToRequire
141157

142158
- type: `{ [tag: string]: string | Array<string> }`

docs/en/workflow/linting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Linting
22

3-
You may have been wondering how do you lint your code inside `*.vue` files, since they are not JavaScript. We will assume you are using [ESLint](http://eslint.org/) (if you are not, you should!).
3+
You may have been wondering how do you lint your code inside `*.vue` files, since they are not JavaScript. We will assume you are using [ESLint](https://eslint.org/) (if you are not, you should!).
44

55
You will also need the [eslint-plugin-html](https://github.com/BenoitZugmeyer/eslint-plugin-html) which supports extracting and linting the JavaScript inside `*.vue` files.
66

docs/en/workflow/testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
> The [webpack vue-cli template](https://github.com/vuejs-templates/webpack) offers pre-configured unit testing and e2e testing setups for you.
44
5-
When testing `*.vue` files, we cannot use a plain CommonJS-based test runner because it won't know how to handle `*.vue` files. Instead, we still use Webpack + vue-loader to bundle our test files. The recommended setup is using [Karma](http://karma-runner.github.io/0.13/index.html) and [karma-webpack](https://github.com/webpack/karma-webpack).
5+
When testing `*.vue` files, we cannot use a plain CommonJS-based test runner because it won't know how to handle `*.vue` files. Instead, we still use Webpack + vue-loader to bundle our test files. The recommended setup is using [Karma](https://karma-runner.github.io/0.13/index.html) and [karma-webpack](https://github.com/webpack/karma-webpack).
66

7-
Karma is a test runner that launches browsers and runs your tests for you. You can choose what browsers you want to test in and what test framework (e.g. Mocha or Jasmine) you want to use. Here is an example Karma configuration that runs the tests inside [PhantomJS](http://phantomjs.org/) with the [Jasmine](http://jasmine.github.io/edge/introduction.html) test framework:
7+
Karma is a test runner that launches browsers and runs your tests for you. You can choose what browsers you want to test in and what test framework (e.g. Mocha or Jasmine) you want to use. Here is an example Karma configuration that runs the tests inside [PhantomJS](http://phantomjs.org/) with the [Jasmine](https://jasmine.github.io/edge/introduction.html) test framework:
88

99
``` bash
1010
npm install\

docs/ja/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
- [cssSourceMap](options.md#csssourcemap)
2727
- [esModule](options.md#esmodule)
2828
- [preserveWhitespace](options.md#preservewhitespace)
29+
- [compilerModules](options.md#compilermodules)
30+
- [compilerDirectives](options.md#compilerdirectives)
2931
- [transformToRequire](options.md#transformtorequire)
3032
- [buble](options.md#buble)
3133
- [extractCSS](options.md#extractcss)

docs/ja/configurations/pre-processors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ npm install sass-resources-loader --save-dev
5656
}
5757
```
5858

59-
例として、[vuejs-templates/webpack](https://github.com/vuejs-templates/webpack) を使用している場合、 `build/util.js` を以下のように変更してください:
59+
例として、[vuejs-templates/webpack](https://github.com/vuejs-templates/webpack) を使用している場合、 `build/utils.js` を以下のように変更してください:
6060

6161
``` js
6262
scss: generateLoaders('sass').concat(

docs/ja/features/postcss.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PostCSS
22

3-
`vue-loader`により処理されたCSSのアウトプットはスコープされたCSSにに書き換えるために[PostCSS](https://github.com/postcss/postcss) を通します。カスタムされた PostCSSプラグインをプロセスに追加することが出来ます。例えば、[autoprefixer](https://github.com/postcss/autoprefixer)[CSSNext](http://cssnext.io/)があります。
3+
`vue-loader`により処理されたCSSのアウトプットはスコープされたCSSに書き換えるために[PostCSS](https://github.com/postcss/postcss) を通します。カスタムされた PostCSSプラグインをプロセスに追加することが出来ます。例えば、[autoprefixer](https://github.com/postcss/autoprefixer)[CSSNext](http://cssnext.io/)があります。
44

55
## 設定ファイルの使用
66

docs/ja/options.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,26 @@ module.exports = {
132132
### preserveWhitespace
133133

134134
- 型: `boolean`
135-
- デフォルトx: `true`
135+
- デフォルト: `true`
136136

137137
もし `false` に設定されていたら、テンプレート内の HTML タグ間の空白は無視されます。
138138

139+
### compilerModules
140+
141+
- 型: `Array<ModuleOptions>`
142+
- デフォルト: `[]`
143+
144+
`vue-template-compiler``modules` オプションを設定します。詳細については `vue-template-compiler`[`modules` option](https://github.com/vuejs/vue/blob/dev/packages/vue-template-compiler/README.md#compilercompiletemplate-options) を参照してください。
145+
146+
### compilerDirectives
147+
148+
- 型: `{ [tag: string]: Function }`
149+
- デフォルト: `{}` (v13.0.5 以降)
150+
151+
> バージョンメモ: v12.x においては、v12.2.3 以降からサポートされます。
152+
153+
`vue-template-compiler``directives` オプションを設定します。詳細については `vue-template-compiler`[`directives` option](https://github.com/vuejs/vue/blob/dev/packages/vue-template-compiler/README.md#compilercompiletemplate-options) を参照してください。
154+
139155
### transformToRequire
140156

141157
- 型: `{ [tag: string]: string | Array<string> }`

docs/ja/start/spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default {
5151

5252
- デフォルトの言語は `js``babel-loader``buble-loader` が検出される場合、自動的にES2015がサポートされる)
5353
- それぞれの `*.vue` ファイルは最大で一つの `<script>` ブロックを含みます
54-
- スクリプトは CommonJS のように処理されます( Webpack 経由でバンドルされた通常の `.js` モジュールと同じです)。つまり他の依存関係を `recuire()` することができます。そして ES2015 がサポートされ、`import``export` 構文を使用することが出来ます
54+
- スクリプトは CommonJS のように処理されます( Webpack 経由でバンドルされた通常の `.js` モジュールと同じです)。つまり他の依存関係を `require()` することができます。そして ES2015 がサポートされ、`import``export` 構文を使用することが出来ます
5555
- スクリプトは Vue.js コンポーネントのオプションオブジェクトをエクスポートする必要があります。 `Vue.extend()` によって拡張されたコンストラクタもエクスポートすることが可能ですが、プレーンなオブジェクトが好ましいです
5656

5757
#### `<style>`

docs/ru/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
Если вы уже знакомы с Webpack, можете пропустить дальнейшее объяснение. Для тех же, кому Webpack в новинку, вот краткая вводная:
2323

24-
[Webpack](http://webpack.github.io/) – это сборщик модулей. Он берёт кучу файлов, рассматривая каждый как модуль, разрешает зависимости между ними и собирает их в статические ресурсы, готовые к развёртыванию.
24+
[Webpack](https://webpack.github.io/) – это сборщик модулей. Он берёт кучу файлов, рассматривая каждый как модуль, разрешает зависимости между ними и собирает их в статические ресурсы, готовые к развёртыванию.
2525

26-
![webpack](http://webpack.github.io/assets/what-is-webpack.png)
26+
![webpack](https://webpack.github.io/assets/what-is-webpack.png)
2727

2828
В качестве простого примера, представим, что у нас есть набор модулей CommonJS. Они не могут запускаться прямо в браузере, так что нам нужно "собрать" их в единый файл, который можно будет вставить на страницу через тег `<script>`. Webpack может сделать это за нас, следуя инструкциям `require()`.
2929

docs/ru/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
- [cssSourceMap](options.md#csssourcemap)
2727
- [esModule](options.md#esmodule)
2828
- [preserveWhitespace](options.md#preservewhitespace)
29+
- [compilerModules](options.md#compilermodules)
30+
- [compilerDirectives](options.md#compilerdirectives)
2931
- [transformToRequire](options.md#transformtorequire)
3032
- [buble](options.md#buble)
3133
- [extractCSS](options.md#extractcss)

docs/ru/configurations/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Чтобы сделать это укажите опцию `loaders` для `vue-loader`:
1212

13-
> Опции `preLoaders` и `postLoaders` доступны только в версиях >=10.3.0
13+
> Опции `preLoaders` и `postLoaders` доступны только в версиях 10.3.0+
1414
1515
### Webpack 2.x
1616

docs/ru/configurations/pre-processors.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,40 @@ npm install sass-loader node-sass --save-dev
3737

3838
Обратитесь к разделу [продвинутой конфигурации загрузчиков](./advanced.md) для получения дополнительной информации о том, как настраивать vue-loader.
3939

40+
#### Загрузка глобального файла настроек
41+
42+
Часто встречаются просьбы добавить возможность загружать файл настроек в каждом компоненте без необходимости явно импортировать его каждый раз, например для использования SCSS-переменных глобально во всех компонентах. Для этого нужно:
43+
44+
``` bash
45+
npm install sass-resources-loader --save-dev
46+
```
47+
48+
Затем добавить новое правило в Webpack:
49+
50+
``` js
51+
{
52+
loader: 'sass-resources-loader',
53+
options: {
54+
resources: path.resolve(__dirname, '../src/style/_variables.scss')
55+
}
56+
}
57+
```
58+
59+
Например, если вы используете [vuejs-templates/webpack](https://github.com/vuejs-templates/webpack), измените файл `build/utils.js` таким образом:
60+
61+
``` js
62+
scss: generateLoaders('sass').concat(
63+
{
64+
loader: 'sass-resources-loader',
65+
options: {
66+
resources: path.resolve(__dirname, '../src/style/_variables.scss')
67+
}
68+
}
69+
),
70+
```
71+
72+
В этот файл рекомендуется включать только переменные, примеси и т.п., чтобы предотвратить дублирование CSS в финальных скомпилированных файлах.
73+
4074
### JavaScript
4175

4276
Весь JavaScript внутри Vue компонентов обрабатывается `babel-loader` по умолчанию. При необходимости это можно изменить:

0 commit comments

Comments
 (0)