forked from xiazeyu/live2d-widget.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
103 lines (93 loc) · 2.57 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const webpack = require('webpack');
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const visualizer = require('webpack-visualizer-plugin');
const manifestPlugin = require('webpack-manifest-plugin');
const nowDate = new Date();
const isProd = e => e === 'prod';
module.exports = env => {
return {
node: {
fs: "empty"
},
entry: [
'core-js/fn/promise',
'./src/wpPublicPath.js',
'./src/index.js',
],
output: {
filename: 'L2Dwidget.min.js',
// YOU MUST INSTALL babel-plugin-syntax-dynamic-import FIRST TO ENABLE CODE SPLITTING!
chunkFilename: 'L2Dwidget.[id].min.js',
library: 'L2Dwidget',
libraryExport: 'L2Dwidget',
libraryTarget: 'var',
path: path.resolve(__dirname, 'lib'),
pathinfo: (isProd(env) ? false : true),
},
target: 'web',
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,
},
},
}),
// 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()}`),
/**
* Webpack Manifest Plugin
* https://github.com/danethurber/webpack-manifest-plugin
*/
new manifestPlugin(),
/**
* Webpack Visualizer
* https://github.com/chrisbateman/webpack-visualizer
*/
new visualizer(),
],
resolve: {
extensions: ['.js', '.html', '.webpack.js', '.web.js', '.ts'],
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, "src"),
use: [{
loader: 'babel-loader',
}],
},
{
test: /\.html$/,
use: [{
loader: 'html-loader',
options: {
minimize: true,
},
}],
},
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader'
}
]
},
}
}