Closed DevTGhosh closed 1 week ago
The JS assets are fallback to index.html
and showed these errors, can you provide your rsbuild.config.ts
?
Related documentation: https://rsbuild.dev/guide/basic/server#page-routing
import { defineConfig, loadEnv } from '@rsbuild/core'
import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill'
import { pluginReact } from '@rsbuild/plugin-react'
import { pluginSvgr } from '@rsbuild/plugin-svgr'
import { pluginSass } from '@rsbuild/plugin-sass'
const { publicVars } = loadEnv({ prefixes: ['REACT_APP_'] })
export default defineConfig({
plugins: [
pluginReact(),
pluginSvgr({ mixedImport: true }),
pluginNodePolyfill(),
pluginSass(),
],
html: {
template: './public/index.html',
},
source: {
define: publicVars,
},
output: {
distPath: {
root: 'build',
},
assetPrefix: 'auto',
},
})
I've also encountered this issue
@DevTGhosh as a temporary solution you can override publicPath
in rspack
config:
tools: {
rspack(config) {
config.output = {
...config.output,
publicPath: '/'
};
}
}
@eidellev that seems to have fixed the issue with the blank page, Thanks.
Still getting issues with favicons not loading. <%= assetPrefix %>
seems to be resolving to auto
. Any idea?
@DevTGhosh favicon
worked out of the box for me. what is the actual HTML for favicon
that's being generated?
@DevTGhosh
favicon
worked out of the box for me. what is the actual HTML forfavicon
that's being generated? You need add this configoutput: { assetPrefix: '/', copy: [ { from: './public/favicon.ico' }, ], },
There was an issue with my config. Fixing that solved the favicon issue. Thanks everyone for the help.
considering that the tools > rspack config can change anytime. A better solution should be there for the publicPath
issue.
你好,如果你看到我这封邮件,说明我已收到你的信息。若有问题我会抽空回复你。
Version
Details
After running the build command and opening any page directly that isn't the
/
page I am getting a blank page and a bunch of errors in the console. It is working fine on the dev server but the production build is causing an issue. The project is being converted from a cra 4 app to rsbuild. The issue seems to be accessing any protected route in react router v6 directly. Console errors.Reproduce link
don't have a reproducible link
Reproduce Steps