简体   繁体   English

webpack sass-loader仅加载必要的.scss文件。

[英]webpack sass-loader load only neccessary .scss files.

Is it possible to only load the appropriate .scss files? 是否可以仅加载适当的.scss文件? For some reason even though a react component isn't being used on a page the .scss file is still being included in my css. 由于某些原因,即使页面上未使用React组件,.scss文件仍包含在我的CSS中。

I am currently using ExtractTextPlugin since I also want sourcemaps to work. 我目前正在使用ExtractTextPlugin,因为我也希望源地图能够正常工作。

You could look into react-proxy-loader It will allow you to load components and their dependancies on demand. 您可以研究react-proxy-loader它将允许您按需加载组件及其相关性。

I'm assuming what is happening for you right now is all your code is being delivered as one or two bundles, so it makes since that some components that may not be in use (along with their required css) would still be included with the bundle. 我假设现在发生的事情是您的所有代码都以一捆或两捆的形式交付,因此这样做是因为某些未使用的组件(以及所需的CSS)仍将包含在其中。束。

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

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