-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.js
58 lines (53 loc) · 1.5 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
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isProd = (args) => {
return args.mode === 'production'
}
const outputFolder = (args) => path.resolve(__dirname, 'dist/bundles');
const bundleFilename = (args) => {
return 'kontent-management.umd' + (isProd(args) ? '.min.js' : '.js');
}
module.exports = (env, args) => ({
mode: args.mode,
entry: {
'index': './lib/index.ts',
},
resolve: {
extensions: ['.ts', '.js']
},
output: {
path: outputFolder(args),
filename: bundleFilename(args),
libraryTarget: 'umd',
umdNamedDefine: true,
library: 'kontentManagement'
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
include: [
path.resolve(__dirname, 'lib'),
],
options: {
configFile: require.resolve('./tsconfig.webpack.json')
}
}
],
},
performance: {
hints: 'warning',
maxEntrypointSize: 1000000,
maxAssetSize: 1000000
},
plugins: [
new BundleAnalyzerPlugin({
generateStatsFile: true,
analyzerMode: 'json',
reportFilename: (isProd(args) ? 'report.min' : 'report') + '.json',
statsFilename: (isProd(args) ? 'stats.min' : 'stats') + '.json'
})
]
});