-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
webpack.config.js
58 lines (55 loc) · 1.55 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
const path = require('path');
const fs = require('fs');
const CopyPlugin = require('copy-webpack-plugin');
const SCRIPTS_INPUT_DIR = './src/scripts';
const SCRIPTS_OUTPUT_DIR = './scripts';
const scriptEntryPoints = {};
fs.readdirSync(SCRIPTS_INPUT_DIR)
.filter((f) => f.endsWith('.ts'))
.forEach(
(f) => (scriptEntryPoints[path.basename(f, '.ts')] = './' + path.join(SCRIPTS_INPUT_DIR, f))
);
module.exports = (env) => ({
mode: env.development ? 'development' : 'production',
entry: {
'chart-info': './src/chart-info/main.ts',
'classic-layout': './src/classic-layout/main.tsx',
'dx-achievement': './src/dx-achievement/main.tsx',
'index-page': './src/index-page/main.tsx',
'plate-progress': './src/plate-progress/main.tsx',
'rating-calculator': './src/rating-calculator/main.ts',
'rating-visualizer': './src/rating-visualizer/main.tsx',
...scriptEntryPoints,
},
output: {
path: `${__dirname}/build`,
filename: (pathData) => {
const chunkName = pathData.chunk.name;
if (scriptEntryPoints[chunkName]) {
return path.join(SCRIPTS_OUTPUT_DIR, chunkName + '.js');
}
return chunkName + '/main.bundle.js';
},
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'ts-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new CopyPlugin({
patterns: [{from: 'public/', to: './'}],
}),
],
});