【发布时间】:2018-09-17 07:30:38
【问题描述】:
我对 Safari 版本
我在控制台中收到此错误:
意外的关键字“const”。严格模式不支持 const 声明。
我尝试使用 @babel/preset-stage-0 但 babel 删除了它。
这是我的应用配置:
.babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-transform-object-assign"
]
}
webpack.config.js
const path = require("path");
const webpack = require("webpack");
const componentName = "contact-captain";
const publicFolderRelativePath = "../../../../public/js";
const ignorePlugin = new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/);
module.exports = {
// devtool: "source-map",
output: {
path: path.resolve(__dirname, publicFolderRelativePath),
filename: `${componentName}.js`
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
},
plugins: [
ignorePlugin
]
};
【问题讨论】:
-
曹奥尔加。 “@babel/preset-stage-0 但 babel 删除了它”是什么意思?
-
当我尝试构建我的项目时,我收到了这个错误:我们已经删除了 Babel 的舞台预设。请考虑阅读我们关于此决定的博客文章babeljs.io/blog/2018/07/27/removing-babels-stage-presets 我不确定改用什么
-
好的。不知道。谢谢!
-
我也有同样的问题。无论我在 .babelrc 中设置什么配置,它都不起作用...