Skip to content

Remove extract-loader #1090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2025
Merged

Remove extract-loader #1090

merged 2 commits into from
Jun 20, 2025

Conversation

Mr0grog
Copy link
Member

@Mr0grog Mr0grog commented Jun 19, 2025

The old extract-loader Webpack plugin is no longer maintained and is the source of all our remaining dependency security warnings. Looking at its issue tracker, it seems like there are also a number of edge-cases where it does not work correctly with Webpack 5 that have been slowly piling up (we haven't hit those yet, but who knows when that might happen). This switches to the currently recommended by Webpack mini-css-extract-plugin.

The main difference here is that this outputs a single bundled CSS file (<root>/bundle.css) instead of converting the individual files by themselves. I think that’s probably OK.

An alternative would be to have postcss-loader write the files out itself. That gets us something more like the old file structure, but feels like it’s cutting against the grain a bit. It also seems like sourcemaps get lost when I do that, although I’m sure that, with enough fiddling, I could figure out how to put them back. For future reference, that webpack config would look like:

      {
        test: /\.css$/,
        type: 'asset/resource',
        generator: {
          filename: removeSrcDirectory
        },
        exclude: [
          path.resolve(__dirname, 'node_modules')
        ],
        // Only process legacy CSS files
        include: [
          path.resolve(__dirname, 'src/css/styles.css'),
          path.resolve(__dirname, 'src/css/diff.css')
        ],
        use: [
          // {
          //   loader: 'extract-loader',
          // },
          // {
          //   loader: 'css-loader',
          //   options: {
          //     import: false,
          //     sourceMap: true
          //   },
          // },
          {
            loader: 'postcss-loader',
            options: {
              sourceMap: true,
              postcssOptions: {
                plugins: [
                  autoprefixer()
                ]
              }
            },
          },
        ],
      },

The old extract-loader Webpack plugin is no longer maintained and is the source of all our remaining dependency security warnings. Looking at its issue tracker, it seems like there are also a number of edge-cases where it does not work correctly with Webpack 5 that have been slowly piling up (we haven't hit those yet, but who knows when that might happen). This switches to the currently recommended by Webpack mini-css-extract-plugin.
@Mr0grog Mr0grog mentioned this pull request Jun 19, 2025
14 tasks
@Mr0grog Mr0grog merged commit 0b00a50 into main Jun 20, 2025
4 checks passed
@Mr0grog Mr0grog deleted the extract-extract-loader branch June 20, 2025 01:36
@github-project-automation github-project-automation bot moved this from Inbox to Done in Web Monitoring Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant