本质上我得到Uncaught ReferenceError: require is not defined
在控制台中它指向:
var fooBarGold = require('../bower_components/scrollup/dist/lib/jquery-1.11.1.min.js');
所以在文件(jquery.scrollUp.js)
中我试图利用browserify,我有上面的内容;
我尝试导入的文件(在这种情况下为jquery-1.11.1.min.js
)包含如下:
module.exports = function(){
//jquery
};
这是我的一项任务:
gulp.task('browserify', ['scripts'], function() {
return browserify('./builds/development/js/app.js')
.bundle()
.pipe(source('app.js'))
.pipe(gulpif(env === 'production', gulp.dest(outputDir + 'js')));
});
这是我的脚本任务,(请注意:正如您可以通过我的脚本任务的长度看到的,我很乐意转向浏览器,以便我可以摆脱所有的流程)
gulp.task('scripts', function() {
return streamqueue({
objectMode: true
},
gulp.src('builds/development/bower_components/jquery/jquery.js'),
gulp.src('builds/development/bower_components/fastclick/lib/fastclick.js'),
gulp.src('builds/development/bower_components/mixitup/src/jquery.mixitup.js'),
gulp.src('builds/development/bower_components/flexslider/jquery.flexslider.js'),
gulp.src('builds/development/bower_components/angular/angular.js'),
gulp.src('builds/development/bower_components/angular-animate/angular-animate.js'),
gulp.src('builds/development/bower_components/angular-route/angular-route.js'),
gulp.src('builds/development/bower_components/angular-ui-router/release/angular-ui-router.js'),
gulp.src('builds/development/bower_components/angular-flexslider/angular-flexslider.js'),
gulp.src('builds/development/bower_components/angular-foundation/mm-foundation-tpls.js'),
gulp.src('builds/development/bower_components/foundation/js/vendor/modernizr.js'),
gulp.src('components/js/rustyApp.js'),
gulp.src('components/js/share.js'),
gulp.src('builds/development/bower_components/uikit/js/uikit.js'),
// gulp.src('builds/development/bower_components/scrollup/dist/lib/jquery-1.11.1.min.js'),
gulp.src('builds/development/bower_components/scrollup/dist/jquery.scrollUp.js'),
gulp.src('builds/development/bower_components/foundation/js/foundation.js'),
gulp.src('components/js/index_scripts.js'))
.pipe(jshint())
.pipe(concat('app.js'))
// browserify('development/js/app.js')
// .pipe(source('app.js'))
// .pipe(gulpif(env === 'production', ngAnnotate()))
.pipe(gulpif(env === 'production', uglify({
mangle: false
}).on('error', function(e) {
console.log('\x07', e.message);
return this.end();
})))
.pipe(plumber())
.pipe(notify({
message: "Script tasks have been completed!"
}))
.pipe(gulp.dest(outputDir + 'js'));