๐Ÿ“ฆ malash / webpack-issue-9053

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/malash/webpack-issue-9053.git
HTTPS git clone https://github.com/malash/webpack-issue-9053.git
SSH git clone git@github.com:malash/webpack-issue-9053.git
CLI gh repo clone malash/webpack-issue-9053
Malash Malash add bad case 09b0d51 6 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ dist
๐Ÿ“„ .gitignore
๐Ÿ“„ file.js
๐Ÿ“„ LICENSE
๐Ÿ“„ package-lock.json
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ webpack.config.js
๐Ÿ“„ README.md

webpack-inline-match-resource-issue

This is am implement demo from the inline matchResouce document for Webpack.

The extract-style-loader/index convert file.js from

/* STYLE: body { background: red; } */
console.log('yep');

to

import './file.js.css!=!extract-style-loader/getStyles!./file.js';
console.log('yep');

To generate standalone .css file I use the file-loader to handle it:

// webpack.config.js
module.exports = {
  mode: process.env.NODE_ENV || "development",
  devtool: "none",
  entry: resolve(__dirname, "./file.js"),
  output: {
    path: resolve(__dirname, "dist"),
    filename: "index.js"
  },
  module: {
    rules: [
      {
        test: /\.js/,
        use: [
          {
            loader: require.resolve("./extract-style-loader")
          }
        ]
      },
      {
        test: /\.css/,
        use: [
          {
            loader: "file-loader",
            options: {
              name: "[path][name].css"
            }
          }
        ]
      }
    ]
  }
};

It's expected to be:

file-loader!extract-style-loader/getStyles!./file.js

which means the extract-style-loader/getStyles extract a virtual file called file.js.css and then passed to the file-loader.

but in fact it is:

extract-style-loader/getStyles|file-loader!./file.js

The file-loader will write the original file.js to dist and return module.exports = __webpack_public_path__ + "file.css" and then the extract-style-loader/getStyles failds.