-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.client.config.js
55 lines (54 loc) · 1.53 KB
/
webpack.client.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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = (env, argv) => {
const isDevelopment = argv.mode === 'development';
return {
mode: isDevelopment ? 'development' : 'production',
entry: './src/index.tsx', // Entry point of the React app
output: {
path: path.resolve(__dirname, 'dist'), // Output directory
filename: 'bundle.js', // Bundled JavaScript file
clean: true, // Clean the output directory before each build
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: 'ts-loader', // Transpile TypeScript
},
{
test: /\.(scss|sass)$/,
use: [
'style-loader', // Injects styles into DOM
'css-loader', // Translates CSS into CommonJS
'sass-loader', // Compiles Sass to CSS
],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'], // Resolve these extensions
fallback: {
fs: false,
path: false,
},
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html', // Reference to the base HTML file
}),
],
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
compress: true,
port: 3000, // Development server port
client: {
logging: 'warn', // Reduce console logging
},
},
devtool: isDevelopment ? 'eval-source-map' : 'source-map',
};
};