javascript - Core-JS 3 Babel 导致 mini-css-extract-plugin 错误
问题描述
从这个问题开始,我已经设置了我的 Webpack 4 配置来处理babel-loader
这样的问题
{
module : {
rules : [{
test : /\.js$/,
// Some module should not be transpiled by Babel
// See https://github.com/zloirock/core-js/issues/743#issuecomment-572074215
exclude: ['/node_modules/', /\bcore-js\b/, /\bwebpack\/buildin\b/, /@babel\/runtime-corejs3/],
loader : "babel-loader",
options : {
babelrc : false,
// Fixes "TypeError: __webpack_require__(...) is not a function"
// https://github.com/webpack/webpack/issues/9379#issuecomment-509628205
// https://babeljs.io/docs/en/options#sourcetype
sourceType : "unambiguous",
presets : [
["@babel/preset-env", {
// Webpack supports ES Modules out of the box and therefore doesn’t require
// import/export to be transpiled resulting in smaller builds, and better tree
// shaking. See https://webpack.js.org/guides/tree-shaking/#conclusion
modules : false,
// Adds specific imports for polyfills when they are used in each file.
// Take advantage of the fact that a bundler will load the polyfill only once.
useBuiltIns : "usage",
corejs : {
version : "3",
proposals : true
}
}]
]
}
}
}
}
当我在浏览器中运行它时,我得到了这个我不明白的错误:
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: Cannot convert undefined or null to object
解决方法是什么?在这个问题之后,我到处搜索代码开始import 'core-js
,但在任何地方都看不到它,所以已经走到了死胡同。
解决方案
我遇到了类似的问题,原因是 Babel 正在编译我的 css-loader webpack 插件。看这里:MiniCssExtractPlugin error on entry point build
推荐阅读
- python - Python、Pandas:自上而下标记占总销售额 80% 的行
- google-sheets - 谷歌表格超链接
- c++ - 为什么我们需要 std::boolean 以及它的用途是什么?
- python - 启用将 HTML 表单发布到 Django 数据库后端
- c - 在标头中使用私有函数作为c中的#define
- sql - 在 oracle 中修改表上的 CHECK 约束的最佳方法是什么?
- typescript - 如何在使用 Puppeteer 时录制音频?
- spring-boot - 从 application.properties 调试一个不满意的绑定作为 spring-boot 启动?
- python - 如何通过不同的 csv 文件迭代选择的操作并将结果输出到新的 csv 文件
- svg - 规模
SVG中的元素