1// webpack.config.mjs:核心配置
2import { resolve } from 'node:path';
3import fileBasedRouter from '@feoe/fs-router/webpack';
4import HtmlWebpackPlugin from 'html-webpack-plugin';
5
6export default {
7 mode: 'production',
8 entry: './src/main.tsx',
9 output: { path: resolve('dist/webpack'), filename: 'app.js', publicPath: '/', clean: true },
10 resolve: { extensions: ['.tsx', '.ts', '.js'] },
11 module: { rules: [{
12 test: /\.tsx?$/, exclude: /node_modules/,
13 use: { loader: 'ts-loader', options: { transpileOnly: true, compilerOptions: { noEmit: false, allowImportingTsExtensions: false } } },
14 }] },
15 plugins: [fileBasedRouter(), new HtmlWebpackPlugin({ template: './bundler.html' })],
16};