-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (53 loc) · 1.45 KB
/
webpack.config.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
const webpack = require('webpack')
const fs = require('fs')
const dir = __dirname //当前模块文件所在目录
const env = process.env //webpack执行环境
var plugins = [
new webpack.NoErrorsPlugin(),
]
switch (env.task) {
//开发环境
case 'dev':
break;
//生产环境
case 'build':
plugins.push(
//相当于 webpack -p
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
)
break;
}
module.exports = {
entry: {
'map': './index.js',
},
output: {
publicPath: '',// 开发代码中url的转换拼接处理,通常是代码中各种资源的地址,比如图片等, url目录前缀或完整网址url前缀'http://cdn.com/'
path: __dirname,
filename: 'examples/js/[name].js'
},
//script引入js类库,通过require或import的方式来使用,却不希望webpack把它编译到输出文件中。
externals: {
},
//自动补全的后缀
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
},
module: {
preLoaders: [
{ test: /\.ts$/, loader: 'ts-loader' }
],
loaders: [
{
test: /\.js(x)?$/,
exclude: /(node_modules|bower_components)/,//npm,bower
loader: 'babel-loader'
}
],
},
plugins: plugins
}