-
Notifications
You must be signed in to change notification settings - Fork 400
Expand file tree
/
Copy pathwebpack.config.mjs.js
More file actions
91 lines (84 loc) · 2.14 KB
/
webpack.config.mjs.js
File metadata and controls
91 lines (84 loc) · 2.14 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
90
91
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, 'core.ts')) || fs.existsSync(path.join(pluginDir, 'index.ts'));
})
.reduce((acc, pluginName) => {
const pluginDir = path.join(pluginsDir, pluginName);
const entryFile = fs.existsSync(path.join(pluginDir, 'core.ts')) ? 'core.ts' : 'index.ts';
acc[pluginName] = `./src/plugins/${pluginName}/${entryFile}`;
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: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.mjs.json',
},
},
],
exclude: /node_modules/,
},
],
},
experiments: {
outputModule: true,
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'VanillaCalendarPro': 'vanilla-calendar-pro'
}
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].mjs',
libraryTarget: 'module',
},
externals: {
jquery: 'jQuery',
lodash: '_',
apexcharts: 'ApexCharts',
'datatable.net-dt': 'DataTable',
dropzone: 'Dropzone',
clipboard: 'ClipboardJS',
noUiSlider: 'noUiSlider',
VanillaCalendarPro: 'VanillaCalendarPro'
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
},
};