You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -66,11 +65,56 @@ And this is all you need to do in your main entry file:
66
65
```js
67
66
// main.js
68
67
var Vue =require('vue')
69
-
var appOptions =require('./app.vue')
70
-
var app =newVue(appOptions).$mount('#app')
68
+
var App =require('./app.vue')
69
+
70
+
newVue({
71
+
el:'body',
72
+
components: {
73
+
app: App
74
+
}
75
+
})
76
+
```
77
+
78
+
In your HTML:
79
+
80
+
```html
81
+
<body>
82
+
<app></app>
83
+
<scriptsrc="build.js"></script>
84
+
</body>
85
+
```
86
+
87
+
## ES2015 by Default
88
+
89
+
`vue-loader` automatically applies Babel transforms to the JavaScript inside `*.vue` components. Write ES2015 today!
90
+
91
+
The default Babel options used for Vue.js components are:
92
+
93
+
```js
94
+
{
95
+
// use babel-runtime library for common helpers
96
+
optional: ['runtime'],
97
+
// use loose mode for faster builds
98
+
loose:'all',
99
+
// disable non-standard stuff (e.g. JSX)
100
+
nonStandard:false
101
+
}
102
+
```
103
+
104
+
If you wish to mofidy this, you can add a `babel` field in your webpack config, which will be merged with the default options. For example:
105
+
106
+
```js
107
+
// webpack.config.js
108
+
module.exports= {
109
+
// other configs...
110
+
babel: {
111
+
// enable stage 0 transforms
112
+
stage:0
113
+
}
114
+
}
71
115
```
72
116
73
-
## Pre-Processors
117
+
## CSS Pre-Processors
74
118
75
119
`vue-loader` allows you to use other Webpack loaders to pre-process the different parts inside your `*.vue` components. Just specify the loader to use with the `lang` attribute (you also need to install the loader, obviously):
76
120
@@ -204,9 +248,7 @@ For a complete example with hot reloading in action, see [vue-hackernews](https:
204
248
By default, `vue-loader` will try to use the loader with the same name as
205
249
the `lang` attribute, but you can configure which loader should be used.
206
250
207
-
#### Example: Using ES6 with Babel
208
-
209
-
To apply Babel transforms to all your JavaScript, use this Webpack config:
251
+
#### Example: Use CoffeeScript for all `<script>` tags
210
252
211
253
```js
212
254
var vue =require('vue-loader')
@@ -218,23 +260,15 @@ module.exports = {
218
260
{
219
261
test:/\.vue$/,
220
262
loader:vue.withLoaders({
221
-
// apply babel transform to all javascript
222
-
// inside *.vue files.
223
-
js:'babel?optional[]=runtime'
263
+
js:'coffee'
224
264
})
225
265
}
226
266
]
227
267
},
228
-
devtool:'source-map'
268
+
devtool:'#source-map'
229
269
}
230
270
```
231
271
232
-
Some explanantions:
233
-
234
-
1. Here `js` is the default language for `<script>` blocks.
235
-
236
-
2. The `?optional[]=runtime` query string passed to the loader. This instructs Babel to use helper functions from the `babel-runtime` NPM package instead of injecting the helpers into every single file. You'll want this most of the time.
237
-
238
272
#### Example: Extracting CSS into a Single File
239
273
240
274
To extract out the generated css into a separate file,
0 commit comments