zoukankan      html  css  js  c++  java
  • webpack配置babel

    src/test1.js

    function f() {
        console.log(arguments)
    }
    
    function ff(a = 1) {
        console.log(a)
        return f(...arguments)
    }
    ff(1, 2, 3, 4)

    webpack.config.js

    module.exports = {
        entry: './src/test1.js',
        target: 'web',
        module: {
            rules: [
                {
                    test: /.m?js$/,
                    exclude: /(node_modules|bower_components)/,
                    use: {
                        loader: 'babel-loader',
                        options: {
                            presets: [
                                [
                                    '@babel/preset-env', {
                                        useBuiltIns: "usage",
                                        targets: {
                                            browsers: "last 2 versions, not ie <= 9"
                                        }
                                    }
                                ]
                            ],
                            plugins: [
                                "@babel/transform-runtime",
                                "@babel/plugin-transform-modules-commonjs"
                            ]
                        }
                    }
                }
            ]
        },
        mode: 'development'
        // mode: 'production',
    };

    package.json

    {
      "name": "webpack-babel",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "build": "webpack -p"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "@babel/core": "^7.12.10",
        "@babel/plugin-transform-modules-commonjs": "^7.12.1",
        "@babel/plugin-transform-runtime": "^7.12.10",
        "@babel/preset-env": "^7.12.11",
        "babel-loader": "^8.2.2",
        "webpack": "^4.44.1",
        "webpack-cli": "^3.3.12"
      },
      "dependencies": {
        "@babel/polyfill": "^7.12.1"
      }
    }
  • 相关阅读:
    83. Remove Duplicates from Sorted List
    141. Linked List Cycle
    hdu1028 划分数
    XDU1019 阶乘因子的个数
    poj2773 容斥原理
    poj1091 容斥原理的应用
    poj1173 多重集组合数
    HDU 1465 错排问题
    poj 1496
    复习之求一个数的约束之积模一个质数
  • 原文地址:https://www.cnblogs.com/413xiaol/p/14320468.html
Copyright © 2011-2022 走看看