开发环境中,react项目界面是这样
使用npm run build打包之后,把dist下的文件放到node服务器上就变成了这样:
为什么用npm run build打包之后样式会丢失呢?
欢迎选择我的课程,让我们一起见证您的进步~~
Path problem, try to use node to proxy the dist directory to the root directory.
First of all, you have to list what libraries you use for packaging and how to configure them.
Then take a look at your packaged path, and the path to import css in the packaged page, is it correct? Whether publicPath is set
Go to the index.js file in the config folder to find the build object, and change the "/" in assetsPublicPath to "./"
Open the chrome debugging interface, what’s wrong
If nothing else, it should be a path problem. The best way is to look at the console error report, find your root path, and then match your style path based on the root path.
Path problem, try to use node to proxy the dist directory to the root directory.
First of all, you have to list what libraries you use for packaging and how to configure them.
Then take a look at your packaged path,
and the path to import css in the packaged page, is it correct?
Whether publicPath is set
Go to the index.js file in the config folder to find the build object, and change the "/" in assetsPublicPath to "./"
Open the chrome debugging interface, what’s wrong
If nothing else, it should be a path problem. The best way is to look at the console error report, find your root path, and then match your style path based on the root path.