-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
53 lines (49 loc) · 1.08 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
const path = require('path');
const fs = require('fs');
const mode = process.env.NODE_ENV || 'development';
const dir = [__dirname, 'packages', process.env.LD_PKG];
const baseConfig = {
// experiments: {outputModule: true},
mode,
entry: {},
output: {
path: path.resolve(...dir, 'build'),
filename: '[name].js',
clean: true,
},
resolve: {
extensions: ['.js', '.jsx'],
symlinks: false,
},
module: {
rules: [
{
test: /\.jsx?$/i,
loader: 'swc-loader',
exclude: [],
},
{
test: /\.(sa|s?c)ss$/i,
use: [
'css-loader',
],
},
{
test: /\.(eot|woff2?|ttf|svg|png|jpe?g|gifv?|webp)$/i,
type: 'asset',
generator: {
filename: 'demo/[hash][ext][query]',
},
},
],
},
optimization: {
usedExports: false,
},
};
if (fs.existsSync(path.join(...dir, 'src/index.mjs'))) {
baseConfig.entry.main = path.resolve(...dir, 'src/index.mjs');
} else {
baseConfig.entry.main = path.resolve(...dir, 'src/index');
}
module.exports = baseConfig