【问题标题】:React not loading from babel.rc file反应不从 babel.rc 文件加载
【发布时间】:2016-05-03 19:48:07
【问题描述】:

我在尝试使用 Babel6 Stage-1 加载我的 React 应用程序时收到“模块解析失败”错误。我们最初运行的是 browserify,但我现在正试图将我们完全移植到 Babel6。

babel.rc 文件

{
"presets": ["stage-1", "react"],
"env": {
  "development": {
   "presets": ["react-hmre"]
}
}}

webpack 配置

var path = require('path');
var webpack = require('webpack');

module.exports = {
  devtool: 'cheap-module-eval-source-map',
  entry: [
    'eventsource-polyfill', // necessary for hot reloading with IE
    'webpack-hot-middleware/client',
    './src/index'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: '/static/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  module: {
    loaders: [{
      test: /\.jsx?/,
      loaders: ['babel'],
      include: path.join(__dirname, 'src'),
    },
    {
     test: /\.css$/,
     exclude: /node_modules/,
     loader: 'style!css'
   }]
  }
};

我已尝试阅读有关 Babel6 的文档,看来我需要在我的预设中包含 react 以及 Stage-1。

我都完成了,并且安装了 npm:

babel preset stage 1、babel preset react、babel preset react hmre

关于如何再次加载反应的任何想法?

【问题讨论】:

标签: node.js reactjs babeljs transpiler ecmascript-2016


【解决方案1】:

通过在 babel.rc 文件中添加 es2015 修复

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-07
    • 2019-10-10
    • 2021-08-20
    • 2019-04-30
    • 1970-01-01
    • 2019-07-23
    • 2017-05-12
    • 2018-06-07
    相关资源
    最近更新 更多