This commit is contained in:
wxhao
2025-10-31 14:26:32 +08:00
parent ba4e7b55e2
commit 43534e3ef4
11 changed files with 5738 additions and 31 deletions

74
webpack.config.js Normal file
View File

@@ -0,0 +1,74 @@
import path from 'path';
import { fileURLToPath } from 'url';
// 处理ES模块中的__dirname
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default {
entry: './src/index.tsx',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
clean: true,
},
mode: 'development',
devtool: 'eval-cheap-module-source-map',
devServer: {
static: {
directory: __dirname,
},
hot: true,
open: true,
port: 3000,
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
noEmit: false
}
}
}
],
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: 'defaults' }],
'@babel/preset-react',
],
},
},
},
{
test: /\.(scss|sass)$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js'],
},
};