尝试将redux整合到反应中。 Webpack对store.js感到窒息

我正在尝试将REDX集成到现有的反应应用程序中。 我所有的反应代码都在jsx文件中。 现在我介绍了REDX和一个store.js。 在编译webpack时出现store.js上的令牌错误

webpack.config.js

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

var BUILD_DIR = path.resolve(__dirname, 'project/static/public/js');
var APP_DIR = path.resolve(__dirname, 'project/static/public/js/components');


module.exports = {
  entry: APP_DIR + '/App.jsx',
  output: {
    path: BUILD_DIR,
    filename: 'bundle.js'
  },
  resolve: {
    alias: {
      'react': path.join(__dirname, 'node_modules', 'react')
    }
  },
  module : {
    loaders : [
      {
        test : /.jsx/,
        include : APP_DIR,
        loader : 'babel',
        presets : ['es2015']
      },
      {
        test : /.js/,
        include : BUILD_DIR,
        exclude : /bundle.js||bundle.js.map||node_modules/,
        loader : 'babel',
        presets : ['es2015']
      }
    ]
  },
  watchOptions: {
    poll: true
  }

};

.babelrc

{
  "presets": [
    "es2015",
    "react"
  ],
  "env": {
    "start": {
      "presets": [
        "react-hmre"
      ]
    }
  },
  "plugins": [
      ["transform-es2015-arrow-functions", { "spec": true }],
      ["transform-class-properties"]
    ]
}

store.js

import { applyMiddleware, createStore} from 'redux';
import combineReducers from './reducers/index.js'


export default createStore(combineReducers)

错误信息

./project/static/public/js/store.js中的错误模块解析失败:/home/username/git/project/project/static/public/js/store.js第1行:

意外的标记您可能需要一个适当的加载器来处理这种文件类型。 | 从'redux'导入{applyMiddleware,createStore}; | 从'./reducers/index.js'|导入combineReducers @ ./project/static/public/js/components/App.jsx 15:13-32

这些文件在尝试解析和更好地理解redux时经历了多次迭代。 我认为问题出在我的webpack配置上。

链接地址: http://www.djcxy.com/p/52161.html

上一篇: Trying to integrate redux into react application. Webpack is choking on store.js

下一篇: Rendering React components from an HTML string