-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.babel.js
77 lines (73 loc) · 1.93 KB
/
webpack.config.babel.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
import path from 'path';
import TerserWebpack from 'terser-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
const libraryName = 'purejs';
const plugins = [];
const minimizer = [
new TerserWebpack({
parallel: true,
extractComments: false,
terserOptions: {
ecma: 8,
compress: { warnings: false },
output: {
comments: false,
beautify: false,
},
},
}),
];
const config = {
entry: {
purejs: `${__dirname}/src/index.ts`,
'lib/anchorTo': `${__dirname}/src/lib/anchorTo.ts`,
'lib/animateTo': `${__dirname}/src/lib/animateTo.ts`,
'lib/debounce': `${__dirname}/src/lib/debounce.ts`,
'lib/elementOffsetTop': `${__dirname}/src/lib/elementOffsetTop.ts`,
'lib/events': `${__dirname}/src/lib/events.ts`,
'lib/forEach': `${__dirname}/src/lib/forEach.ts`,
'lib/isExplorer': `${__dirname}/src/lib/isExplorer.ts`,
'lib/isInt': `${__dirname}/src/lib/isInt.ts`,
'lib/isNan': `${__dirname}/src/lib/isNan.ts`,
'lib/safeScrollTop': `${__dirname}/src/lib/safeScrollTop.ts`,
'lib/scrollDirection': `${__dirname}/src/lib/scrollDirection.ts`,
'lib/touchable': `${__dirname}/src/lib/touchable.ts`,
},
mode: 'production',
devtool: 'source-map',
output: {
path: `${__dirname}`,
filename: `[name].js`,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
},
optimization: {
minimizer,
splitChunks: {
chunks: 'all',
},
},
module: {
rules: [
{
test: /(\.ts)$/,
loader: 'ts-loader',
exclude: /(node_modules)/,
},
],
},
resolveLoader: {
modules: ['node_modules'],
},
resolve: {
modules: [path.resolve('./src'), 'node_modules'],
extensions: ['.json', '.ts', '.js'],
},
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
plugins.push(new BundleAnalyzerPlugin());
}
return { ...config, plugins };
};