Good afternoon everyone,
I have a problem trying to concatenate all my bower components in a single file called vendor.js.
This is my gulp task:
gulp.task('bower', function() {
var jsFilter = gulpFilter('**/*.js', {
restore: true
})
var cssFilter = gulpFilter('**/*.css', {
restore: true
})
return gulp.src(bower(), {
base: 'bower_components'
})
.pipe(jsFilter)
.pipe(order([
"bower_components/jquery/**/*.js",
"bower_components/angular/**/*.js",
"bower_components/moment/**/*.js",
"bower_components/**/*.js"
], {
base: './'
}))
/*.pipe(babel({
presets: ['es2015']
}))*/
.pipe(concat('vendor.js'))
.pipe(gulp.dest(dist.js))
.pipe(jsFilter.restore)
.pipe(cssFilter)
.pipe(concat('vendor.css'))
.pipe(gulp.dest(dist.css))
.pipe(cssFilter.restore)
.pipe(rename(function(path) {
if (~path.dirname.indexOf('fonts')) {
path.dirname = '/fonts'
}
}))
.pipe(gulp.dest(dist.vendor))
})
When I run I receive the following error:
Uncaught ReferenceError: require is not defined
To solve the error as you see, in the commented line I tried to port to ES5 with babel, but if it is not an error it throws me another one.
How do you manage to combine all the components in a css and js file without errors? Is this crazy? My goal is not to have to include each and every one of the bower components by hand.