FakeRainBrigand FakeRainBrigand - 3 months ago 23x
Javascript Question

Webpack loader aliases?

I have a fairly complicated loader setup for style sheets:

test: /\.scss$/,
loader: ExtractTextPlugin.extract("style",
"css?sourceMap&localIdentName=[path][name]__[local]__[hash:base64:5]!sass?outputStyle=expanded&" +
"includePaths[]=" + other stuff)

Which works great, but on some requires I want to add the
option to css-loader, so it'd look like this:


But I can't do this all over the place.

How can I configure this so that I can enable the css-loader modules flag on certain requires while keeping the rest of it the same?

Maybe something like a loader 'alias', e.g.

The only solution I can think of is writing a loader that does a syntax transform to inline the loader config into certain require calls... but that's brittle and complicated.


resolveLoader.alias will work here. Ie.

resolveLoader: {
    alias: {
        'with-modules': 'loader definition goes here',

Using this configuration you can do simply


at your code.