@@ -46,28 +46,28 @@ After proper installation, your `package.json`'s `devDependencies` field should
46
46
``` json
47
47
...
48
48
"devDependencies" : {
49
- "babel-core" : " ^6.3.17" ,
50
- "babel-loader" : " ^6.2.0" ,
51
- "babel-plugin-transform-runtime" : " ^6.3.13" ,
52
- "babel-preset-es2015" : " ^6.3.13" ,
53
- "babel-runtime" : " ^5.8.34" ,
54
- "css-loader" : " ^0.23.0" ,
55
- "vue-hot-reload-api" : " ^1.2.2" ,
56
- "vue-html-loader" : " ^1.0.0" ,
49
+ "babel-core" : " ^6.13.2" ,
50
+ "babel-loader" : " ^6.2.4" ,
51
+ "babel-plugin-transform-runtime" : " ^6.12.0" ,
52
+ "babel-preset-es2015" : " ^6.13.2" ,
53
+ "babel-runtime" : " ^5.8.38" ,
54
+ "css-loader" : " ^0.23.1" ,
55
+ "vue-hot-reload-api" : " ^1.3.3" ,
56
+ "vue-html-loader" : " ^1.2.3" ,
57
+ "vue-loader" : " ^7.5.3" ,
57
58
"vue-style-loader" : " ^1.0.0" ,
58
- "vue-loader" : " ^7.2.0" ,
59
- "webpack" : " ^1.12.9" ,
60
- "webpack-dev-server" : " ^1.14.0"
59
+ "webpack" : " ^1.13.1" ,
60
+ "webpack-dev-server" : " ^1.14.1"
61
61
},
62
62
"dependencies" : {
63
- "vue" : " ^1.0.13 "
64
- },
63
+ "vue" : " ^1.0.26 "
64
+ }
65
65
...
66
66
```
67
67
68
68
### Configuring Webpack
69
69
70
- Here's the most basic Webpack configuration for ` vue-loader ` :
70
+ Here's a basic Webpack configuration for ` vue-loader ` :
71
71
72
72
``` js
73
73
// webpack.config.js
@@ -86,8 +86,19 @@ module.exports = {
86
86
{
87
87
test: / \. vue$ / , // a regex for matching all files that end in `.vue`
88
88
loader: ' vue' // loader to use for matched files
89
- }
89
+ },
90
+ {
91
+ // use babel-loader for *.js files
92
+ test: / \. js$ / ,
93
+ loader: ' babel' ,
94
+ // important: exclude files in node_modules
95
+ // otherwise it's going to be really slow!
96
+ exclude: / node_modules/
97
+ }
90
98
]
99
+ },
100
+ babel: {
101
+ presets: [' es2015' ]
91
102
}
92
103
}
93
104
```
@@ -108,7 +119,7 @@ The app entry point, `main.js` typically looks like this (using ES2015 syntax):
108
119
// main.js
109
120
import Vue from ' vue'
110
121
// require a *.vue component
111
- import App from ' ./components/App'
122
+ import App from ' ./components/App.vue '
112
123
113
124
// mount a root Vue instance
114
125
new Vue ({
@@ -144,14 +155,37 @@ export default {
144
155
</script >
145
156
```
146
157
158
+ Now create a couple of basic sub-components.
159
+
160
+ ` ./components/ComponentA.vue `
161
+ ``` html
162
+ <template >
163
+ <div >Component A</div >
164
+ </template >
165
+ ```
166
+
167
+ ` ./components/ComponentB.vue `
168
+ ``` html
169
+ <template >
170
+ <div >Component B</div >
171
+ </template >
172
+ ```
173
+
147
174
Next, let's create an ` index.html ` that simply uses the bundled file:
148
175
149
176
``` html
150
177
<!-- index.html -->
151
- <body >
152
- <app ></app >
153
- <script src =" build.js" ></script >
154
- </body >
178
+ <!DOCTYPE html>
179
+ <html >
180
+ <head >
181
+ <meta charset =" utf-8" >
182
+ <title >Vue.js Tutorial</title >
183
+ </head >
184
+ <body >
185
+ <app ></app >
186
+ <script src =" build.js" ></script >
187
+ </body >
188
+ </html >
155
189
```
156
190
157
191
### Running It
0 commit comments