当我运行 npm run build 失败时,引用 mini-css-extract-plugin:
C:\dev\udemy-restfull\webpack\node_modules\mini-css-extract-plugin\dist\index.js:76
const resource = this._identifier.split('!').pop();
^
TypeError: Cannot read property 'split' of undefined
Run Code Online (Sandbox Code Playgroud)
我尝试搜索错误,但只知道这取决于加载器执行的顺序,所以我只留下了 MiniCssExtractPlugin.loader 和 css-loader,但错误仍然存在。
我浏览了文档并得到了简化的设置,也发生了同样的错误。
我已经在index.js中加载了引导程序,所以我删除了它,认为这可能是原因,也不好。
你能帮助我吗?
这是我的 webpack.config.js 文件:
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: ["@babel/polyfill", "./src/index.js"],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
plugins: [
new MiniCssExtractPlugin({
filename: 'style.css'
})
],
module: {
rules: [
{
test: /\.css$/,
use: [
{ loader: MiniCssExtractPlugin.loader }, // style-loader
{ loader: "file-loader" }
]
}, …Run Code Online (Sandbox Code Playgroud)