Skip to content
This repository was archived by the owner on Sep 25, 2023. It is now read-only.

Commit b580066

Browse files
committed
step one and two
1 parent dd10748 commit b580066

File tree

7 files changed

+46
-165
lines changed

7 files changed

+46
-165
lines changed

.babelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"presets": ["es2015", "stage-2"],
3-
"plugins": ["transform-runtime"],
4-
"comments": false
2+
"presets": ["es2015", "stage-0"],
3+
"plugins": ["transform-runtime"]
54
}

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>test-vue-webpack</title>
5+
<title>Vue Example</title>
66
</head>
77
<body>
8-
<app></app>
8+
<h3>{{ message }}</h3>
99
<script src="dist/build.js"></script>
1010
</body>
1111
</html>

package.json

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
{
22
"name": "test-vue-webpack",
3+
"version": "1.0.0",
34
"description": "A Vue.js project",
4-
"author": "brandonxiang",
5-
"private": true,
5+
"main": "src/main.js",
66
"scripts": {
7-
"dev": "webpack-dev-server --inline --hot",
8-
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
7+
"test": "echo \"Error: no test specified\" && exit 1"
98
},
10-
"dependencies": {
11-
"babel-runtime": "^5.8.0",
12-
"leaflet": "^0.7.7",
13-
"vue": "^1.0.0"
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/brandonxiang/example-vue-webpack.git"
12+
},
13+
"keywords": [
14+
"vue",
15+
"webpack"
16+
],
17+
"author": "brandonxiang",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/brandonxiang/example-vue-webpack/issues"
1421
},
22+
"homepage": "https://github.com/brandonxiang/example-vue-webpack#readme",
1523
"devDependencies": {
16-
"babel-core": "^6.0.0",
17-
"babel-loader": "^6.0.0",
18-
"babel-plugin-transform-runtime": "^6.0.0",
19-
"babel-preset-es2015": "^6.0.0",
20-
"babel-preset-stage-2": "^6.0.0",
21-
"cross-env": "^1.0.6",
22-
"css-loader": "^0.23.0",
23-
"file-loader": "^0.8.4",
24-
"json-loader": "^0.5.4",
25-
"url-loader": "^0.5.7",
26-
"vue-hot-reload-api": "^1.2.0",
27-
"vue-html-loader": "^1.0.0",
28-
"vue-loader": "^8.2.1",
29-
"vue-style-loader": "^1.0.0",
30-
"webpack": "^1.12.2",
31-
"webpack-dev-server": "^1.12.0"
24+
"babel-core": "^6.1.2",
25+
"babel-loader": "^6.1.0",
26+
"babel-plugin-transform-runtime": "^6.1.2",
27+
"babel-preset-es2015": "^6.1.2",
28+
"babel-preset-stage-0": "^6.1.2",
29+
"babel-runtime": "^5.8.0",
30+
"webpack": "^1.12.2"
31+
},
32+
"dependencies": {
33+
"vue": "^1.0.26"
3234
}
3335
}

src/App.vue

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/leaflet.vue

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import Vue from 'vue';
2-
import App from './App.vue';
1+
import Vue from 'vue'
32

4-
var example1 = new Vue({
3+
new Vue({
54
el: 'body',
6-
components: { App }
7-
});
5+
data: {
6+
message: "Hello Vue"
7+
}
8+
})

webpack.config.js

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,24 @@
1-
var path = require('path')
2-
var webpack = require('webpack')
3-
41
module.exports = {
2+
// 这是一个主文件包括其他模块
53
entry: './src/main.js',
4+
// 编译的文件路径
65
output: {
7-
path: path.resolve(__dirname, './dist'),
8-
publicPath: '/dist/',
6+
//`dist`文件夹
7+
path: './dist',
8+
// 文件 `build.js` 即 dist/build.js
99
filename: 'build.js'
1010
},
11-
resolveLoader: {
12-
root: path.join(__dirname, 'node_modules'),
13-
},
1411
module: {
12+
// 一些特定的编译规则
1513
loaders: [
1614
{
17-
test: /\.vue$/,
18-
loader: 'vue'
19-
},
20-
{
15+
// 让webpack去验证文件是否是.js结尾将其转换
2116
test: /\.js$/,
17+
// 通过babel转换
2218
loader: 'babel',
19+
// 不用转换的node_modules文件夹
2320
exclude: /node_modules/
24-
},
25-
{
26-
test: /\.json$/,
27-
loader: 'json'
28-
},
29-
{
30-
test: /\.html$/,
31-
loader: 'vue-html'
32-
},
33-
{
34-
test: /\.(png|jpg|gif|svg)$/,
35-
loader: 'url',
36-
query: {
37-
limit: 10000,
38-
name: '[name].[ext]?[hash]'
39-
}
4021
}
4122
]
42-
},
43-
devServer: {
44-
historyApiFallback: true,
45-
noInfo: true
46-
},
47-
devtool: '#eval-source-map'
48-
}
49-
50-
if (process.env.NODE_ENV === 'production') {
51-
module.exports.devtool = '#source-map'
52-
// http://vuejs.github.io/vue-loader/workflow/production.html
53-
module.exports.plugins = (module.exports.plugins || []).concat([
54-
new webpack.DefinePlugin({
55-
'process.env': {
56-
NODE_ENV: '"production"'
57-
}
58-
}),
59-
new webpack.optimize.UglifyJsPlugin({
60-
compress: {
61-
warnings: false
62-
}
63-
}),
64-
new webpack.optimize.OccurenceOrderPlugin()
65-
])
23+
}
6624
}

0 commit comments

Comments
 (0)