-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.base.js
51 lines (48 loc) · 1.43 KB
/
webpack.base.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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const distDir = path.join(__dirname, 'dist')
function generateBase(stage) {
return {
mode: 'development',
entry: './src/index.tsx',
output: {
filename: '[name].[fullhash].' + Math.floor(Date.now() / 60000) + '.js',
path: distDir,
publicPath: '/',
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json', '.css'],
alias: {
configuration: path.join(__dirname, 'config', stage),
},
fallback: { events: require.resolve('events/') },
},
module: {
rules: [
{ test: /\.tsx?$/, loader: 'swc-loader', exclude: /node_modules/ },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.(png|jpeg|svg|ico)/, type: 'asset/resource' },
{ test: /\.ne$/, use: ['@leetcode/nearley-loader'] },
{ test: /\.md$/, type: 'asset/source' },
],
},
devServer: {
compress: true,
host: '0.0.0.0',
hot: true,
historyApiFallback: true,
},
devtool: 'eval-source-map',
plugins: [
new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
resource.request = resource.request.replace(/^node:/, '')
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
favicon: 'src/icon.svg',
}),
],
}
}
module.exports = generateBase