-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
53 lines (52 loc) · 1.77 KB
/
webpack.config.js
File metadata and controls
53 lines (52 loc) · 1.77 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
entry: './src/index.tsx', // Entry file
output: {
filename: 'bundle.js', // Output file
path: path.resolve(__dirname, 'dist'), // Output directory
},
devtool: 'inline-source-map', // Generate source map
module: {
rules: [
{
test: /\.(js|jsx|)$/, // Match .js, .jsx files
exclude: /node_modules/,
use: {
loader: 'babel-loader', // Use babel-loader
},
},
{
test: /\.(ts|tsx)$/, // Match .ts, .tsx files
exclude: /node_modules/,
use: {
loader: 'ts-loader', // Use ts-loader
options: {
transpileOnly: true,
}
},
},
{
test: /\.css$/, // Match .css files
use: ['style-loader', 'css-loader'], // Use CSS Loader and Style Loader
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html', // Use HTML template file
}),
new CleanWebpackPlugin(), // Clean output directory
new ForkTsCheckerWebpackPlugin(),
],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'], // Support omitting file extensions when importing
},
devServer: {
static: './dist', // Dev server static files root
port: 3000, // Specify port
hot: true, // Enable Hot Module Replacement (HMR)
},
};