-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
77 lines (73 loc) · 1.96 KB
/
webpack.config.js
File metadata and controls
77 lines (73 loc) · 1.96 KB
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
'use strict';
let htmlWebpackPlugin = require('html-webpack-plugin');
let webpack = require('webpack');
let defaultSettings = require('./config/defaults');
let path = require('path');
let fs = require('fs');
let config = {
entry:defaultSettings.getDefaultentry(),
output:{
path:path.resolve(__dirname, '../build'),
filename: "script/[name].[hash:6].js",
jsonpFunction:'Topthinking',
chunkFilename: "script/[name].[chunkhash:6].js"
},
plugins: [
new webpack.LoaderOptionsPlugin({
options:{
postcss:()=>{
return [
require('autoprefixer')({
"broswers":["last 5 versions"]
})
];
}
}
}),
new webpack.optimize.UglifyJsPlugin({
compress:{
warnings: false
},
beautify:false,
comments:false
}),
new htmlWebpackPlugin({
chunks: ['app', 'vendor'],
template:'./src/app.html',
favicon:'./src/app.jpg',
filename:'index.html',
inject:'body',
minify:{
removeEmptyAttributes: true,
removeAttributeQuotes: true,
collapseBooleanAttributes: true,
collapseWhitespace: true
}
}),
new webpack.optimize.CommonsChunkPlugin({
"name":"vendor",
"filename":"script/vendor.[hash:6].js"
})
],
module: defaultSettings.getDefaultModules()
};
var deleteFolder = function(path) {
var files = [];
if( fs.existsSync(path) ) {
files = fs.readdirSync(path);
files.forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.statSync(curPath).isDirectory()) { // recurse
deleteFolder(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
deleteFolder('../build/script/');
deleteFolder('../build/images/');
deleteFolder('../build/fonts/');
deleteFolder('../build/style/');
module.exports = config;