Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用babel的多个版本_Javascript_Reactjs_Babeljs - Fatal编程技术网

Javascript 使用babel的多个版本

Javascript 使用babel的多个版本,javascript,reactjs,babeljs,Javascript,Reactjs,Babeljs,我有这个。巴别LRC { "presets": [ ["es2015", {"modules": false}], "stage-2", "react" ], "plugins": [ "react-hot-loader/babel" ] } 但在另一个任务中,我需要阶段0,是否可以为babel创建条件case?上面的配置是针对webpack 2的,不幸的是其他东西坏了,因为它使用了babel的stage-0。您可以使用webpack的url参数

我有这个。巴别LRC

{
  "presets": [
    ["es2015", {"modules": false}],
    "stage-2",
    "react"
  ],
  "plugins": [
    "react-hot-loader/babel"
  ]
}

但在另一个任务中,我需要阶段0,是否可以为babel创建条件case?上面的配置是针对webpack 2的,不幸的是其他东西坏了,因为它使用了babel的stage-0。

您可以使用webpack的
url
参数为babel提供不同的配置

范例

webpack.prod.js

{
    test: /\.js$/,
    exclude: /(node_modules|bower_components)/,
    loader: 'babel-loader',
    query: {
      presets: [
        ["es2015", {"modules": false}],
        "stage-2",
        "react"
      ],
      plugins: [
        "react-hot-loader/babel"
      ]
    }
}
{
    test: /\.js$/,
    exclude: /(node_modules|bower_components)/,
    loader: 'babel-loader',
    query: {
      presets: [
        ["es2015", {"modules": false}],
        "stage-0",
        "stage-2",
        "react"
      ],
      plugins: [
        "react-hot-loader/babel"
      ]
    }
}
webpack.stage.js

{
    test: /\.js$/,
    exclude: /(node_modules|bower_components)/,
    loader: 'babel-loader',
    query: {
      presets: [
        ["es2015", {"modules": false}],
        "stage-2",
        "react"
      ],
      plugins: [
        "react-hot-loader/babel"
      ]
    }
}
{
    test: /\.js$/,
    exclude: /(node_modules|bower_components)/,
    loader: 'babel-loader',
    query: {
      presets: [
        ["es2015", {"modules": false}],
        "stage-0",
        "stage-2",
        "react"
      ],
      plugins: [
        "react-hot-loader/babel"
      ]
    }
}
参考:


希望这有帮助

这只是运行2个不同的网页包文件,我想运行npm测试。