-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
83 lines (79 loc) · 2.1 KB
/
webpack.config.js
File metadata and controls
83 lines (79 loc) · 2.1 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
78
79
80
81
82
83
'use strict';
let htmlWebpackPlugin = require('html-webpack-plugin');
let webpack = require('webpack');
let CleanPlugin = require('clean-webpack-plugin');
let defaultSettings = require('./cfg/defaults');
let path = require('path');
let fs = require('fs');
let config = {
entry:{
app:'./src/app.js',
vendor: [
"jquery",
"font-awesome-webpack",
"bootstrap-loader",
"angular",
'angular-ui-router',
'oclazyload',
'./src/common/lib/angular-toastr/index',
'./src/common/lib/angular-bootstrap/index',
'angular-file-upload'
]
},
output:{
path:'./dist/static/',
filename: "script/[name].[hash:6].js",
jsonpFunction:'Topthinking',
publicPath:"/static/",
chunkFilename: "script/[name].[chunkhash:6].js"
},
resolve:{
root:__dirname+'./src/'
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress:{
warnings: false
},
beautify:false,
comments:false
}),
new htmlWebpackPlugin({
chunks: ['app', 'vendor'],
favicon:'./src/favicon.ico',
template:'./src/app.html',
filename:'index.html',
inject:'body',
minify:{
removeEmptyAttributes: true,
removeAttributeQuotes: true,
collapseBooleanAttributes: true,
collapseWhitespace: true
}
}),
new webpack.ProvidePlugin({
$:'jquery',
jQuery:"jquery",
"window.jQuery":"jquery"
}),
new webpack.optimize.CommonsChunkPlugin('vendor', '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('./dist/static/');
module.exports = config;