You can, but they wonβt load as CSS files (with ExtractTextPlugin), but from JS that introduces the loader style (this is completely normal).
There are only a few things. Make sure you have configured the CSS / SASS / LESS /...- loader correctly. If ExtractTextPlugin is already working, you are well versed in this issue. Then also make sure fallbackLoader
set to style-loader
(and allChunks
set to the default value: false
) in your ExtractTextPlugin.extract({})
loader.
At this point, just use require.ensure
or System.import
to require / import your CSS files, just like with the code. Thanks to the magic of webpack, everything will just magically work!
source share