我对 Safari 版本 <= 9 有问题。Babel 似乎没有用 var 替换 const。
我在控制台中收到此错误:
意外的关键字“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
]
};