Open History to see the last commit
1import path from 'path'
2import { fileURLToPath } from 'url'
3import HtmlWebpackPlugin from 'html-webpack-plugin'
4import { tanstackRouter } from '@tanstack/router-plugin/webpack'
5β
6const __dirname = fileURLToPath(new URL('.', import.meta.url))
7β
8/** @type import('webpack').Configuration */
9export default ({ WEBPACK_SERVE }) => ({
10 target: 'web',
11 mode: WEBPACK_SERVE ? 'development' : 'production',
12 entry: path.resolve(__dirname, './src/index.tsx'),
13 output: {
14 path: path.resolve(__dirname, './dist'),
15 filename: '[name].bundle.js',
16 publicPath: '/',
17 },
18 resolve: {
19 extensions: ['.ts', '.tsx', '.js', '.jsx'],
20 },
21 plugins: [
22 new HtmlWebpackPlugin({
23 template: path.resolve(__dirname, './public/index.html'),
24 filename: 'index.html',
25 }),
26 tanstackRouter({ target: 'solid', autoCodeSplitting: true }),
27 ],
28 module: {
29 rules: [
30 {
31 test: /\.tsx?$/,
32 exclude: /(node_modules)/,
33 use: { loader: 'babel-loader' },
34 },
35 {
36 test: /\.css$/,
37 use: ['style-loader', 'css-loader', 'postcss-loader'],
38 },
39 ],
40 },
41 devServer: {
42 open: true,
43 hot: true,
44 historyApiFallback: {
45 rewrites: [{ from: /./, to: '/index.html' }],
46 },
47 static: ['public'],
48 },
49})