我在汇总中使用svelte。我需要支持IE11
我当前在rollup.config.js中的babel配置是:
babel({
extensions: [ '.js', '.mjs', '.html', '.svelte' ],
exclude: 'node_modules/**',
presets: [
[
'@babel/env',
{
modules: 'false',
targets: {
browsers: '> 1%, IE 11, not op_mini all, not dead',
node: 8
},
useBuiltIns: 'usage'
}
]
]
}),
[请帮助我进行配置,现在我的应用在IE和其他浏览器(Chrome,Mozilla)上都同时中断。
我发现了一些链接,其中他们正在使用rollup-plugin-babel将Babel与Rollup.js一起使用。
您可以参考下面的步骤。
((1)安装所需的软件包:
npm install @babel/core @babel/preset-env rollup-plugin-babel --save-dev
(2)上面的命令将像这样更新我们的开发依赖项:
// the versions might be different in your case depending on the time reading this
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"rollup": "^1.10.0",
"rollup-plugin-babel": "^4.3.2"
}
((3)接下来,我们需要在应用程序文件夹中创建一个babel配置文件.babelrc,其内容如下:
{
"presets": [
"@babel/env"
]
}
(4)更新rollup.config.js
import babel from 'rollup-plugin-babel';
export default {
input: './src/main.js',
output: {
file: './build/bundle.min.js',
format: 'iife',
name: 'bundle'
},
plugins: [
babel({
exclude: 'node_modules/**'
})
]
}
请参阅这些链接以获取详细说明: