Add dev:web (rsbuild) and dev:cli (tttk serve ./content), with dev running both via scripts/dev.mjs, which shuts both down when either exits. Also add tttk:inspect for --inspect debugging. Both servers previously defaulted to port 3000, so the CLI could not bind while the web dev server was running and the proxy targeted itself. Pin the web dev server to 5173; the CLI keeps 3000 to match the proxy. Document the two-process setup and inspector debugging in docs/development.md.
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { defineConfig } from "@rsbuild/core";
|
|
import { pluginBabel } from "@rsbuild/plugin-babel";
|
|
import { pluginSolid } from "@rsbuild/plugin-solid";
|
|
import tailwindcss from "@tailwindcss/postcss";
|
|
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
pluginBabel({
|
|
include: /\.(?:jsx|tsx)$/,
|
|
}),
|
|
pluginSolid(),
|
|
],
|
|
tools: {
|
|
postcss: {
|
|
postcssOptions: {
|
|
plugins: [tailwindcss()],
|
|
},
|
|
},
|
|
rspack: {
|
|
resolve: {
|
|
// Allow TypeScript sources to use explicit `.js` specifiers (required
|
|
// by the CLI's NodeNext build) while the bundler resolves them to .ts.
|
|
extensionAlias: {
|
|
".js": [".ts", ".tsx", ".js"],
|
|
},
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
// Built-in doc entries are statically imported as strings
|
|
test: /[\\/]doc-entries[\\/].*\.md$/,
|
|
type: "asset/source",
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
process.env.ANALYZE ? new BundleAnalyzerPlugin() : undefined,
|
|
].filter(Boolean),
|
|
},
|
|
},
|
|
html: {
|
|
template: "./src/index.html",
|
|
},
|
|
source: {
|
|
entry: {
|
|
index: "./src/main.tsx",
|
|
},
|
|
},
|
|
server: {
|
|
// Dev web server runs on its own port; the CLI content server keeps
|
|
// port 3000 (see the proxy targets below).
|
|
port: 5173,
|
|
proxy: {
|
|
// Proxy content API requests to the CLI dev server (npm run tttk)
|
|
"/__CONTENT_INDEX.json": "http://localhost:3000",
|
|
"/__COMPLETIONS.json": "http://localhost:3000",
|
|
"/content": "http://localhost:3000",
|
|
"/.ttrpg": "http://localhost:3000",
|
|
},
|
|
historyApiFallback: true,
|
|
},
|
|
output: {
|
|
distPath: {
|
|
root: "dist/web",
|
|
},
|
|
},
|
|
});
|