Skip to content

Commit 8301d7c

Browse files
iotawebyyx990803
authored andcommitted
Update tutorial.md (vuejs#313)
Suggested changes to the tutorial for anybody trying to get it to work using the code examples. This was to overcome an error: Unexpected token import in build.js, i.e. import Vue from 'vue' in main.js line 4. Please bear in mind I am completely new to vue.js and vue-loader, so may have been missing something.
1 parent 4c8376e commit 8301d7c

File tree

1 file changed

+54
-20
lines changed

1 file changed

+54
-20
lines changed

docs/en/start/tutorial.md

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,28 @@ After proper installation, your `package.json`'s `devDependencies` field should
4646
``` json
4747
...
4848
"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",
5758
"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"
6161
},
6262
"dependencies": {
63-
"vue": "^1.0.13"
64-
},
63+
"vue": "^1.0.26"
64+
}
6565
...
6666
```
6767

6868
### Configuring Webpack
6969

70-
Here's the most basic Webpack configuration for `vue-loader`:
70+
Here's a basic Webpack configuration for `vue-loader`:
7171

7272
``` js
7373
// webpack.config.js
@@ -86,8 +86,19 @@ module.exports = {
8686
{
8787
test: /\.vue$/, // a regex for matching all files that end in `.vue`
8888
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+
}
9098
]
99+
},
100+
babel: {
101+
presets: ['es2015']
91102
}
92103
}
93104
```
@@ -108,7 +119,7 @@ The app entry point, `main.js` typically looks like this (using ES2015 syntax):
108119
// main.js
109120
import Vue from 'vue'
110121
// require a *.vue component
111-
import App from './components/App'
122+
import App from './components/App.vue'
112123

113124
// mount a root Vue instance
114125
new Vue({
@@ -144,14 +155,37 @@ export default {
144155
</script>
145156
```
146157

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+
147174
Next, let's create an `index.html` that simply uses the bundled file:
148175

149176
``` html
150177
<!-- 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>
155189
```
156190

157191
### Running It

0 commit comments

Comments
 (0)