forked from jinzhe/vue-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.build.js
executable file
·90 lines (86 loc) · 1.69 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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 = {
app: "./src/app.js",
common: [
'vue',
'vue-router',
'vue-resource',
]
}
config.output = {
path: "./build/static",
publicPath: "https://jinzhe.github.io/vue-calendar/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|mp4)$/,
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',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: "common",
filename: "[name].[hash:3].js"
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
mangle: true,
compress: {
warnings: false
}
})
]
module.exports = config