Closed woody-li closed 10 months ago
When css-loader option exportType= 'string', it got error in file: https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/loader.js#L183
(!originalExports.default || !("locals" in originalExports.default));
Throw an error:
Module build failed TypeError: Cannot use 'in' operator to search for 'locals' in xxxxxxx
Resolve the string data correctly.
webpack config:
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const cssLoader = { loader: 'css-loader', options: { exportType: 'string', }, }; module.exports = { plugins: [new MiniCssExtractPlugin()], module: { rules: [ { test: /\.css$/i, use: [MiniCssExtractPlugin.loader, cssLoader], }, ], }, };
npx webpack-cli info
System: OS: Windows 10 10.0.22621 CPU: (8) x64 AMD EPYC 75F3 32-Core Processor Memory: 9.65 GB / 16.00 GB Binaries: Node: 18.16.1 - C:\Program Files\nodejs\node.EXE npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD Packages: babel-loader: ^9.1.2 => 9.1.2 css-loader: ^6.8.1 => 6.8.1 less-loader: ^11.1.2 => 11.1.3 terser-webpack-plugin: ^5.3.9 => 5.3.9 webpack: ^5.88.1 => 5.88.1
Because you should not to use exportType: 'string' with this plugin, it was design for other purposes I will update docs
exportType: 'string'
Bug report
When css-loader option exportType= 'string', it got error in file: https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/loader.js#L183
Actual Behavior
Throw an error:
Expected Behavior
Resolve the string data correctly.
How Do We Reproduce?
webpack config:
Please paste the results of
npx webpack-cli info
here, and mention other relevant information