node.js - npm run build之后页面样式丢失
天蓬老师
天蓬老师 2017-04-17 16:25:50
0
6
913

开发环境中,react项目界面是这样

使用npm run build打包之后,把dist下的文件放到node服务器上就变成了这样:

为什么用npm run build打包之后样式会丢失呢?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(6)
Peter_Zhu

Path problem, try to use node to proxy the dist directory to the root directory.

Peter_Zhu

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 "./"

PHPzhong

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template