-
Notifications
You must be signed in to change notification settings - Fork 34
/
webpack.config.js
86 lines (79 loc) · 1.9 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
/* eslint-disable @typescript-eslint/no-var-requires */
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
const del = require('del');
const dtpDir = path.resolve(path.dirname(require.resolve('eonasdan-bootstrap-datetimepicker')));
module.exports = (env, argv) => {
const prod = argv.mode !== 'development';
del.sync(`${dtpDir}/../../node_modules/**`);
const nodebbModules = new Set([
'composer',
'composer/formatting',
'translator',
'benchpress',
'alerts',
]);
return {
context: __dirname,
mode: prod ? 'production' : 'development',
devtool: prod ? 'source-map' : 'inline-source-map',
entry: {
client: './src/client/index',
},
output: {
path: path.join(__dirname, './build/bundles'),
filename: '[name].js',
chunkFilename: '[name].[contenthash].js',
},
externals: [
{
jquery: 'jQuery',
utils: 'utils',
},
({ request }, callback) => {
if (nodebbModules.has(request)) {
callback(null, `commonjs ${request}`);
return;
}
callback();
},
],
resolve: {
extensions: ['.js', '.ts'],
alias: {
'./render$': path.resolve(__dirname, './src/calendar/render'),
},
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
include: /node_modules/,
use: './loaders/removeAMD',
},
],
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
sourceMap: true,
},
parallel: true,
}),
],
},
plugins: [
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/,
}),
],
};
};