Error: [BABEL] D:\workspace\pack\src\index.js: Unknown option: .useBuiltIns. Check out https://babeljs.i o/docs/en/babel-core/#options for more information about options.

webpack corejs配置报错

原因:新的配置多了个中括号[]

  • 错误代码
   {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: ‘babel-loader‘,
                options: {

                    presets: [‘@babel/preset-env‘,
                        {
                            //按需加载
                            useBuiltIns: ‘usage‘,
                            corejs: {
                                version: 3
                            },
                            //指定兼容性做到哪个版本的浏览器
                            targets: {
                                chrome: ‘60‘,
                                firefox: ‘60‘,
                                ie: ‘9‘,
                                safari: ‘10‘
                            }
                        }
                    ]

                }
            },
  • 正确代码
 {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: ‘babel-loader‘,
                options: {

                    presets: [[‘@babel/preset-env‘,
                        {
                            //按需加载
                            useBuiltIns: ‘usage‘,
                            corejs: {
                                version: 3
                            },
                            //指定兼容性做到哪个版本的浏览器
                            targets: {
                                chrome: ‘60‘,
                                firefox: ‘60‘,
                                ie: ‘9‘,
                                safari: ‘10‘
                            }
                        }
                    ]]

                }
            },

Error: [BABEL] D:\workspace\pack\src\index.js: Unknown option: .useBuiltIns. Check out https://babeljs.i o/docs/en/babel-core/#options for more information about options.

上一篇:druid数据连接池异常 connection holder is null 解决方案


下一篇:HTML特殊标签