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'
                            }
                        }
                    ]]

                }
            },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM