简体   繁体   English

React Loadable在动态加载的组件中请求新的CSS

[英]React Loadable requesting new css in dynamically loaded components

I'm using react loadable to code split off components. 我正在使用可加载的React来编码分离的组件。 I'm also using Extract CSS Chunks to split my stylesheets up. 我还使用Extract CSS Chunks来拆分样式表。 Everything works great during server side rendering and the initial client side render, but when I transition to a new page and a component is dynamically imported, the JS is being fetched, but the corresponding CSS for the component is not. 在服务器端渲染和初始客户端渲染期间,一切工作都很好,但是当我过渡到新页面并且动态导入组件时,正在获取JS,但没有获取组件的相应CSS。

This wasn't an issue when all my CSS was in one file, but now that it's not, how am I to fetch the CSS along with the JS for dynamically imported components? 当我所有的CSS都放在一个文件中时,这不是问题,但是现在不是了,我如何为动态导入的组件将CSS和JS一起获取? Is that what Webpack Flush Chunks is supposed to help with? 那是Webpack Flush Chunks应该帮助的吗?

Thanks in advance! 提前致谢!

我通过升级到webpack 4并使用mini-css-extract-plugin解决了此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM