-
Notifications
You must be signed in to change notification settings - Fork 414
Expand file tree
/
Copy pathwebpack.config.js
More file actions
89 lines (81 loc) · 2.21 KB
/
Copy pathwebpack.config.js
File metadata and controls
89 lines (81 loc) · 2.21 KB
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
const path = require('path');
const fs = require('fs');
const TerserPlugin = require('terser-webpack-plugin');
const pluginsDir = path.resolve(__dirname, 'src/plugins');
const helperEntries = {
'helper-shared': './src/helpers/shared/index.ts',
'helper-apexcharts': './src/helpers/apexcharts/index.ts',
'helper-clipboard': './src/helpers/clipboard/index.ts',
utils: './src/utils/index.ts',
};
const excludedPluginEntries = new Set(['accessibility-manager', 'base-plugin']);
const pluginEntries = fs
.readdirSync(pluginsDir)
.filter((pluginName) => {
if (excludedPluginEntries.has(pluginName)) return false;
const pluginDir = path.join(pluginsDir, pluginName);
if (!fs.lstatSync(pluginDir).isDirectory()) return false;
return (
fs.existsSync(path.join(pluginDir, 'auto.ts')) ||
fs.existsSync(path.join(pluginDir, 'core.ts'))
);
})
.reduce((acc, pluginName) => {
const pluginDir = path.join(pluginsDir, pluginName);
if (fs.existsSync(path.join(pluginDir, 'auto.ts')))
acc[pluginName] = `./src/plugins/${pluginName}/auto.ts`;
if (fs.existsSync(path.join(pluginDir, 'core.ts')))
acc[`${pluginName}-non-auto`] = `./src/plugins/${pluginName}/core.ts`;
return acc;
}, {});
module.exports = {
mode: 'production',
stats: 'minimal',
entry: {
index: './src/auto/index.ts',
'non-auto': './src/index.ts',
...pluginEntries,
...helperEntries,
},
module: {
rules: [
{ test: /\.ts?$/, enforce: 'pre', use: ['source-map-loader'] },
{ test: /\.ts?$/, use: 'ts-loader', exclude: /node_modules/ },
],
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
VanillaCalendarPro: 'vanilla-calendar-pro',
},
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
library: { type: 'umd' },
},
externals: {
jquery: 'jQuery',
lodash: '_',
apexcharts: 'ApexCharts',
'datatable.net-dt': 'DataTable',
dropzone: 'Dropzone',
clipboard: 'ClipboardJS',
noUiSlider: 'noUiSlider',
VanillaCalendarPro: 'VanillaCalendarPro',
},
optimization: {
moduleIds: 'deterministic',
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
terserOptions: {
format: {
comments: /^!|@preserve|@license|@cc_on/i,
},
},
}),
],
},
};