我正在尝试使用Gulp和Browserify捆绑一个简单的React.js应用程序但是在尝试查找模块时出错了。
gulp是:
%s
index.js文件是:
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
gulp.task('default', function () {
return browserify('./app/index.js', {
debug: false, bundleExternal: true
})
.transform(babelify, {"presets": ["es2015", "react"]})
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./build/js/'));
});
该应用的文件夹结构为:
import React from 'react'
import ReactDOM from 'react-dom'
import routes from 'config/routes'
import users from 'redux/modules/users'
import thunk from 'redux-thunk'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
const store = createStore(users, applyMiddleware(thunk))
ReactDOM.render(
<Provider store={store}>
{routes}
</Provider>,
document.getElementById('app'))
错误消息是:
app/
config/
- routes.js
components/
- component folders + js
index.js => imports all the other .js modules
gulpfile.babel.js
似乎Gulp无法从index.js文件中读取导入内容。有谁知道我可能缺少什么?