question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using extract plugin with IgnorePlugin leads to error

See original GitHub issue

I am not completely sure if this is a bug or feature request, but it is not possible now to skip some imported module if extact css plugin is used.

It seems that this plugin uses css-loader explicitly, so user does not have any way to tell webpack “do not load module bar.css” and trying to do so with IgnorePlugin leads to exception.

The whole story is here: https://stackoverflow.com/questions/58295539/webpack-how-to-exclude-certain-css-file-from-output

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
throwable-onecommented, Oct 10, 2019

Thank you! Here is workaround: use replacement to replace bad_css with empty.css

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');

const pluginToIgnore = /bad_css\.css$/;
module.exports = {
    plugins: [
        new MiniCssExtractPlugin({}),
        new webpack.NormalModuleReplacementPlugin(
            pluginToIgnore,
            '!./empty.css'
        )
    ],
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [MiniCssExtractPlugin.loader, 'css-loader']
            },
        ],
    },
};
0reactions
alexander-akaitcommented, Oct 10, 2019

I will look on this in near future

Read more comments on GitHub >

github_iconTop Results From Across the Web

IgnorePlugin - webpack
The resourceRegExp parameter passed to IgnorePlugin is not tested against the resolved file names or absolute module names being imported or required, but ......
Read more >
How to exclude certain .CSS file from output in Webpack
Solution is to use NormalModuleReplacementPlugin to replace bad file with empty one const MiniCssExtractPlugin ...
Read more >
webpack/webpack - Gitter
Hmms, it half-worked with new webpack.IgnorePlugin(/packery/) but the resulting bundle has errors in it because the module can't be found... Simen Brekken.
Read more >
Adding a Custom webpack Config - Gatsby
There are many plugins in the Gatsby repo using this API to look to for examples e.g. Sass, ... You don't need to...
Read more >
How to use the webpack.NamedModulesPlugin function in ...
https://github.com/jmblog/how-to-optimize-momentjs-with-webpack // You can remove this if you don't use Moment.js: new webpack.IgnorePlugin(/^\.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found