Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
627 views
in Technique[技术] by (71.8m points)

javascript - 从快速js服务器作为静态应用加载时,反应应用样式的组件会松动样式(react app styled components looses styles while loading from express js server as static app)

I have a react app that works standalone and it uses styled-components.

(我有一个独立运行的react应用程序,它使用样式组件。)

For production deployment, I moved it to express server and i have below express config in app.js to load the react app.

(为了进行生产部署,我将其移至Express服务器,并且在app.js中有express配置,以加载react应用。)

// Serve the static files from the React app

(//从React应用提供静态文件)

app.use(express.static(path.join(__dirname, 'client/build')));

while the inline styles works fine, some of the styled-components styles don't work.

(尽管内联样式可以正常工作,但是某些样式化组件样式不起作用。)

I followed below llink but doesn't know how to apply it to my app which doesn't have shared styled components and every component has its own

(我遵循下面的llink,但不知道如何将其应用于没有共享样式组件且每个组件都有自己的应用程序)

https://github.com/styled-components/styled-components-website/blob/master/sections/advanced/server-side-rendering.md

(https://github.com/styled-components/styled-components-website/blob/master/sections/advanced/server-side-rendering.md)

  ask by user3481630 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...