-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.client.js
More file actions
71 lines (68 loc) · 1.95 KB
/
webpack.client.js
File metadata and controls
71 lines (68 loc) · 1.95 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
71
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const isDevelopment = process.env.NODE_ENV !== 'production';
module.exports = {
mode: isDevelopment ? 'development' : 'production',
entry: isDevelopment
? {
index: './src/pages/home/render.js',
'single-work': './src/pages/single-work/render.js',
'work': './src/pages/work/render.js',
'contact': './src/pages/contact/render.js',
}
: {
index: './src/pages/home/hydrate.js',
'single-work': './src/pages/single-work/hydrate.js',
'work': './src/pages/work/hydrate.js',
'contact': './src/pages/contact/hydrate.js',
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js',
publicPath: '/',
},
devServer: {
static: {
directory: path.resolve(__dirname, 'public'),
},
hot: true,
historyApiFallback: {
rewrites: [
{ from: /^\/work$/, to: '/work.html' },
{ from: /^\/work\/.*$/, to: '/single-work.html' }, // Serve single-work.html for dynamic URLs
{ from: /^\/contact$/, to: '/contact.html' },
],
},
port: 3500,
client: {
logging: 'verbose', // Enable verbose logging
},
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
configFile: path.resolve(__dirname, 'babel.client.js'),
},
},
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
},
],
},
plugins: [
new MiniCssExtractPlugin(),
isDevelopment && new ReactRefreshWebpackPlugin(),
new MiniCssExtractPlugin({
filename: 'globals.css',
}),
].filter(Boolean),
devtool: isDevelopment ? 'inline-source-map' : 'source-map',
};