-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
85 lines (76 loc) · 1.66 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
83
84
85
'use strict';
const webpack = require('webpack'),
StringReplacePlugin = require("string-replace-webpack-plugin"),
path = require('path'),
DIST = path.resolve(__dirname, 'lunar/dist'),
env = process.env.WEBPACK_ENV,
config = {
context: __dirname + '/lunar/src',
cacheDirectory: false,
entry: {
lunar: './index.js'
},
resolve: {
extensions: ['', '.js'],
root: [
path.resolve('../install/node_modules')
]
},
output: {
path: DIST,
filename: env === 'dist' ? 'lunar.min.js' : 'lunar.js',
libraryTarget: 'umd',
library: 'Lunar',
umdNamedDefine: true
},
devtool: env === 'dist' ? '' : 'eval-source-map',
resolveLoader: {
modulesDirectories: [
path.resolve('../install/node_modules')
]
},
module: {
loaders: [
{
test: /\.js?$/,
exclude: /(node_modules|dist)/,
loader: 'babel',
query: {
cacheDirectory: true,
presets: ['es2015', 'stage-2'],
plugins: ['transform-runtime', 'add-module-exports', 'transform-es2015-modules-commonjs']
}
}
]
}
};
if(env === 'dist') {
config.plugins = [];
config.plugins.push(new StringReplacePlugin());
config.module.loaders.push({
test: /\.js?$/,
exclude: /(node_modules)/,
loader: StringReplacePlugin.replace({
replacements: [
{
pattern: /Logger\.log\({(.*?)}\);/ig,
replacement: function(match, p1, offset, string) {
return '';
}
}
]
})
});
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false
}
})
);
}
module.exports = config;