Skip to content

Commit 0427b3f

Browse files
committed
Modify the output path and inject way for build files
1 parent 8cbdf56 commit 0427b3f

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

app/templates/_index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
<head>
44
<meta charset="UTF-8">
55
<title><%= appname %></title>
6-
<link rel="stylesheet" href="dist/bundle.css">
76
</head>
87
<body>
98
<app></app>
10-
<script src="dist/bundle.js"></script>
119
</body>
1210
</html>

app/templates/_webpack.config.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
var webpack = require('webpack');
22
var ExtractTextPlugin = require("extract-text-webpack-plugin");
3+
var HtmlWepackPlugin = require('html-webpack-plugin');
34

5+
// basic configurations
46
module.exports = {
57
entry: './src/main.js',
68
output: {
7-
path: './dist/',
8-
publicPath: 'dist/',
9-
filename: 'bundle.js'
9+
path: './dist',
10+
publicPath: '/',
11+
filename: 'static/js/bundle.js'
1012
},
1113
resolve: {
1214
extensions: ['', '.js', '.vue']
@@ -60,10 +62,11 @@ module.exports = {
6062
}
6163
},
6264
plugins: [
63-
new ExtractTextPlugin("bundle.css")
65+
new ExtractTextPlugin("static/css/bundle.css")
6466
]
6567
};
6668

69+
// production configurations
6770
if (process.env.NODE_ENV === 'production') {
6871
module.exports.plugins = module.exports.plugins.concat([
6972
new webpack.DefinePlugin({
@@ -76,12 +79,30 @@ if (process.env.NODE_ENV === 'production') {
7679
warnings: false
7780
}
7881
}),
79-
new webpack.optimize.OccurenceOrderPlugin()
82+
new webpack.optimize.OccurenceOrderPlugin(),
83+
new HtmlWepackPlugin({
84+
filename: 'index.html',
85+
template: 'index.html',
86+
minify: {
87+
removeComments: true,
88+
collapseWhitespace: true
89+
}
90+
})
8091
]);
8192

8293
module.exports.vue.autoprefixer = {
8394
browsers: ['last 2 versions']
8495
}
8596
} else {
97+
// development configurations
98+
module.exports.plugins = module.exports.plugins.concat([
99+
new HtmlWepackPlugin({
100+
filename: 'index.html',
101+
template: 'index.html'
102+
})
103+
]);
104+
module.exports.devServer = {
105+
contentBase: './dist'
106+
};
86107
module.exports.devtool = '#source-map';
87108
}

0 commit comments

Comments
 (0)