-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.common.js
More file actions
70 lines (67 loc) · 1.96 KB
/
webpack.common.js
File metadata and controls
70 lines (67 loc) · 1.96 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
const path = require('path');
const dotenv = require('dotenv');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { DefinePlugin } = require('webpack');
dotenv.config();
module.exports = {
entry: path.resolve(__dirname, './src/index.tsx'),
plugins: [
new DefinePlugin({
'process.env.API_HOST': JSON.stringify(process.env.API_HOST),
}),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin(),
],
module: {
rules: [
{
test: /\.s?css$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[local]-[hash:base64:5]',
},
},
},
'sass-loader',
],
exclude: /node_modules/,
},
{
test: /\.svg/,
type: 'asset/resource',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
'~': path.resolve(__dirname, './src'),
assets: path.resolve(__dirname, './src/assets'),
types: path.resolve(__dirname, './src/types'),
utils: path.resolve(__dirname, './src/utils'),
pages: path.resolve(__dirname, './src/pages'),
hooks: path.resolve(__dirname, './src/hooks'),
stores: path.resolve(__dirname, './src/stores'),
components: path.resolve(__dirname, './src/components'),
constant: path.resolve(__dirname, './src/constant'),
},
fallback: {
path: require.resolve('path-browserify'),
os: require.resolve('os-browserify/browser'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
string_decoder: require.resolve('string_decoder/'),
events: require.resolve('events/'),
buffer: require.resolve('buffer/'),
},
},
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
},
};