Dav*_*rto 6 javascript babel webpack
我将babel与webpack一起使用,试图将箭头功能与Internet Explorer一起使用,但无法正常工作。
这是我的package.json开发依赖项:
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.7.0",
"webpack": "^3.12.0",
"webpack-cli": "^3.1.0"
}
Run Code Online (Sandbox Code Playgroud)
这是我的webpack.config.js:
module.exports = {
entry: ['./chat.js'],
devtool: 'source-map',
output: {
path: path.resolve(__dirname, "dist"),
filename: "chat.js"
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
}
};
Run Code Online (Sandbox Code Playgroud)
我正在使用.babelrc插件:
{
"presets": ["env"],
"plugins": ["transform-class-properties"]
}
Run Code Online (Sandbox Code Playgroud)
我不知道自己在做什么错或缺少什么,但是在Internet Explorer上收到以下语法错误:
DF.fn = () => {
// Content
};
Run Code Online (Sandbox Code Playgroud)
小智 0
您必须为您的构建指定目标浏览器。在此基础上babel-preset-env决定需要应用哪些转换。这是配置的文档和示例
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}]
]
}
Run Code Online (Sandbox Code Playgroud)
这里是指定浏览器集的所有可能方法。
| 归档时间: |
|
| 查看次数: |
3005 次 |
| 最近记录: |