-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.common.js
75 lines (66 loc) · 1.73 KB
/
webpack.config.common.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
const webpack = require('webpack');
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const nowDate = new Date();
const isProd = e => e === 'prod';
module.exports = env => {return{
entry: [
'./src/index.js',
],
output: {
filename: 'L2Dwidget.common.js',
libraryTarget: 'commonjs',
path: path.resolve(__dirname, 'lib'),
pathinfo: (isProd(env) ? false : true),
},
target: 'node',
devtool: 'source-map',
watch: (isProd(env) ? false : true),
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify((isProd(env) ? 'production' : 'development')),
},
}),
new UglifyJsPlugin({
cache: false,
parallel: true,
sourceMap: true,
uglifyOptions: {
// The L2D core library was droped too much,
// so the warnings is useless recently.
warnings: false,
mangle: true,
compress: {
drop_console: false,
},
},
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
// Banner must be put below UglifyJsPlugin, or it won't work.
new webpack.BannerPlugin(`${isProd(env) ? '' : '___DEV___'}https://github.com/xiazeyu/live2d-widget.js built@${nowDate.toLocaleDateString()} ${nowDate.toLocaleTimeString()}`),
],
resolve: {
extensions: ['.js','.html', '.webpack.js', '.web.js'],
},
module: {
rules: [
{test: /\.js$/,
include: path.resolve(__dirname, "src"),
use: [{
loader: 'babel-loader',
}],
},
{test: /\.html$/,
use: [{
loader: 'html-loader',
options: {
minimize: true,
},
}],
},
]
},
}}