forked from frontui/BrickPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.conf.js
92 lines (85 loc) · 1.94 KB
/
webpack.conf.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
91
92
/**
* bundle 使用webpack 打包
* 配置文件
* by tommyshao
*
* webpack --watch
*/
var path = require('path')
var fs = require('fs')
var webpack = require('webpack')
var entryFiles = [];
var srcPath = path.resolve('./src')
var entries = getEntries(srcPath)
function getEntries(folder) {
var paths = path.resolve(folder)
var dirs = fs.readdirSync(paths)
var matchs = [], files = {}
dirs.forEach(function(file) {
matchs = file.match(/(.+)\.js$/)
// 不包含brickplus
if(matchs && matchs[1]) {
// 使用数组才不会抛出模块之间引用的错误
files[matchs[1]] = [path.resolve(folder, file)]
}
})
return files;
}
module.exports = {
entry: entries, // 多入口
devtool: 'source-map',
output: {
path: path.join(__dirname, './static/js/brickplus'),
filename: '[name].js',
library: '[name]',
libraryTarget: 'umd',
sourceMapFilename: '[name].js.map'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
query: {
presets: ['es2015'],
cacheDirectory: true
},
exclude: /node_modules/
}
]
},
resolve: {
alias: {
//jquery: 'bower_components/jquery/dist/jquery.min.js',
zeroPad: './src/Util/zeroPad.js'
},
extensions: ['', '.js'],
root: [path.resolve('./src')]
},
externals: [
{
jquery: {
root: 'jQuery',
commonjs2: 'jquery',
commonjs: 'jquery',
amd: 'jquery'
}
//jquery: true
}
]
}
/**
* production
*/
/*
,
new webpack.optimize.UglifyJsPlugin({
mangle: { // 排除不想要压缩的对象名称
except: ['$super', '$', 'exports', 'require', 'module', '_']
},
compress: {
warnings: false
}
}),
new webpack.NoErrorsPlugin(),
*/