首页 > 解决方案 > react-table styled-components 从 express js 服务器作为静态应用程序加载时会丢失样式

问题描述

我有一个独立工作的反应应用程序,它使用样式组件。我正在使用“styled-components”,“react-table”版本“^4.4.1”,

下面描述了我的 react 生产构建的内容。我没有 app.js 或 index.js 文件

https://create-react-app.dev/docs/production-build/

对于生产部署,我将其移至 express 服务器,并且我在 app.js 中有以下 express 配置来加载反应应用程序。

// 从 React 应用程序提供静态文件

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

虽然内联样式可以正常工作,但某些样式组件样式不起作用。

我按照以下链接进行操作,但不知道如何将其应用于我的应用程序,该应用程序没有共享样式的组件,并且每个组件都有自己的

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

标签: javascriptcssreactjsstyled-componentsreact-table

解决方案


推荐阅读