awesome-webextension / webpack-target-webextension

WebExtension Target for Webpack 5. Supports code-splitting and HMR.
MIT License
46 stars 6 forks source link

`serviceWorkerEntry` breaks `mini-css-extract-plugin` in MV3 only #43

Closed fregante closed 10 months ago

fregante commented 10 months ago

I'm opening this issue to collect some information I find.

Error

Appears in the background worker on load:

Screenshot

Repro

I think the repro so far is:

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

module.exports = {
  plugins: [
    // This is the order in my config
    new WebExtensionTarget({
      weakRuntimeCheck: true,

      background: {
        // it works with `pageEntry` on MV2
        serviceWorkerEntry: "background",
      }
    }),
    new MiniCssExtractPlugin(),
  ],
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, "css-loader"],
      },
    ],
  },
};
import './input.css'
console.log('js loaded')
* {
  color: hotpink;
}

Related

First seen in