-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.build.js
executable file
·73 lines (67 loc) · 1.29 KB
/
webpack.build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var webpack = require('webpack')
var text = require("extract-text-webpack-plugin")
var html = require('html-webpack-plugin')
var fs=require('fs')
function clear(_path) {
if (fs.existsSync(_path)) {
fs.readdirSync(_path).forEach(function(_file, _index) {
var _curPath = _path + "/" + _file
if (fs.statSync(_curPath).isDirectory()) {
clear(_curPath, fs)
} else {
fs.unlinkSync(_curPath)
}
});
fs.rmdirSync(_path)
return true
}
return false
}
clear('./build/')
var config = {}
config.entry ="./src/app.js"
config.output = {
path: "./build/static",
publicPath: "/static/",
filename: "app.[hash:3].js"
}
config.module = {
loaders: [{
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.(png|jpg|gif|ttf|eot|svg|woff)$/,
loader: "file"
}]
}
config.vue = {
loaders: {
css: text.extract("css"),
js: 'babel'
}
}
config.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new text('app.[hash:3].css'),
new html({
filename: '../index.html',
template: './src/app.html',
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
mangle: true,
compress: {
warnings: false
}
})
]
module.exports = config