Webpack 巴贝尔用箭头函数创造生活
我正在尝试使用babel和webpack传输一个极其简单的文件:Webpack 巴贝尔用箭头函数创造生活,webpack,babeljs,arrow-functions,babel-loader,Webpack,Babeljs,Arrow Functions,Babel Loader,我正在尝试使用babel和webpack传输一个极其简单的文件: window.foo = function(bar) { return {...bar}; } 但是,输出(相当大)是 (为了简单起见,我使用了…来简单地缩短输出)。我的webpack.config.js如下所示: const path = require('path'); module.exports = { entry: './src/index.js', output: { pa
window.foo = function(bar) {
return {...bar};
}
但是,输出(相当大)是
(为了简单起见,我使用了…
来简单地缩短输出)。我的webpack.config.js
如下所示:
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'out/'),
filename: 'index.js'
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [["@babel/preset-env", {targets:{"ie": "11"}}]],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-arrow-functions"
]
}
}
}
]
}
};
我的.babelrc
是
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"ie": "11"
},
"useBuiltIns": "entry"
}
]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/transform-arrow-functions",
],
"env": {
"development": {},
"test": {},
"production": {}
}
}
考虑到它是为IE11构建的,它不可能输出箭头函数——为什么?我如何设置配置,使其不输出箭头功能(使其在IE 11中工作)
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"ie": "11"
},
"useBuiltIns": "entry"
}
]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/transform-arrow-functions",
],
"env": {
"development": {},
"test": {},
"production": {}
}
}