开发环境中,react项目界面是这样
使用npm run build打包之后,把dist下的文件放到node服务器上就变成了这样:
为什么用npm run build打包之后样式会丢失呢?
天蓬老师2017-04-17 16:27:50
Path problem, try to use node to proxy the dist directory to the root directory.
天蓬老师2017-04-17 16:27:50
First of all, you have to list what libraries you use for packaging and how to configure them.
ringa_lee2017-04-17 16:27:50
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
迷茫2017-04-17 16:27:50
Go to the index.js file in the config folder to find the build object, and change the "/" in assetsPublicPath to "./"
迷茫2017-04-17 16:27:50
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.