-
Notifications
You must be signed in to change notification settings - Fork 60
/
webpack.config.js
82 lines (81 loc) · 2.02 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
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
const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const NgAnnotatePlugin = require('ng-annotate-webpack-plugin')
module.exports = function(env = {}) {
const isDemo = !!env.isDemo
return {
mode: isDemo ? 'production' : 'development',
entry: {
index: resolve(__dirname, 'demo', 'js', 'index.js')
},
output: {
path: resolve(__dirname, 'build'),
filename: (isDemo ? '[hash].' : '') + '[name].bundle.js',
chunkFilename: (isDemo ? '[hash].' : '') + '[id].bundle.js',
publicPath: isDemo ? '/BaiduMapForAngularJS/' : '/'
},
devtool: isDemo ? '' : '#eval',
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader'
}
]
},
{
test: /\.(js|co)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'es2015',
{
modules: false
}
]
],
plugins: ['transform-object-rest-spread']
}
}
],
exclude: /(node_modules)/
},
{
test: /\.(eot|svg|ttf|woff|woff2|png)\w*/,
use: ['file-loader']
}
]
},
resolve: {
modules: [
resolve(__dirname, 'node_modules'),
resolve(__dirname, 'demo'),
resolve(__dirname, 'demo', 'js')
],
extensions: ['.js', '.co']
},
plugins: (isDemo
? [
new NgAnnotatePlugin({
add: true
})
]
: []
).concat([
new HtmlWebpackPlugin({
filename: 'index.html',
inject: 'body',
template: resolve(__dirname, 'demo', 'index.html'),
favicon: resolve(__dirname, 'demo', 'img', 'favicon.ico'),
hash: false
})
])
}
}