-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
64 lines (62 loc) · 1.44 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
59
60
61
62
63
64
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = (_, argv) => {
const isDevelopment = argv.mode === 'development';
process.env.NODE_ENV = argv.mode;
return {
devtool: isDevelopment ? 'eval-source-map' : 'source-map',
entry: path.resolve(__dirname, 'src/index.jsx'),
mode: argv.mode,
output: {
path: path.join(__dirname, '/build'),
filename: '[name].bundle.js',
clean: true,
},
devServer: {
historyApiFallback: true,
hot: true,
port: 3000,
proxy: {
'/api': {
target: 'http://127.0.0.1:8000',
pathRewrite: { '^/api': '' },
},
},
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.s[ac]ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: { publicPath: '' },
},
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|svg|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$/i,
type: 'asset',
},
],
},
resolve: { extensions: ['*', '.js', '.jsx'] },
optimization: {
splitChunks: { chunks: 'all' },
},
plugins: [
new HtmlWebpackPlugin({ template: './public/index.html' }),
new MiniCssExtractPlugin(),
isDevelopment && new webpack.HotModuleReplacementPlugin(),
].filter(Boolean),
};
};