Roque Roque - 9 months ago 100
CSS Question

Load requirejs module's css dependency with webpack

I am using webpack and I need to include some libraries built for requirejs.
Everything worked fine until one of the library declared a css dependency:

define(["css!./stylesheet.css"], function(){ \* module *\ });

Webpack has a css loader too, however it does not load them automatically as requirejs's one does. One must pipe the css loader to the style loader to do so:


Is there any way to make the prior working? For example, can I overwrite the css loader for this particular library so that it is piped with the style loader ?


I found a nice solution using postLoaders.


postLoaders: [
  { test: /\.css$/, loader: 'style', include: path.join(__dirname, "pathTo/theLib") }

into the module property of the webpack config did the trick.