Skip to content Skip to sidebar Skip to footer

Gulp Concat And Require Path

I have a problem with gulp-concat. I'm trying to concate all my js files in a single file, let's say, dist/app.js. But there is something that I don't understand. In that file, my

Solution 1:

To anyone who might have the same problem. Babel currently doesn't support imports inlining #1681, neither do gulp-concat, as it's just concatenating files.

I opted to use Rollup to propertly resolve dependencies and only then transpile output:

var gulp = require('gulp');
var gutil = require('gulp-util');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var rollup = require('gulp-rollup');

gulp.task('build', function () {
  return gulp.src('src/parser-factory.js', { read: false })
    .pipe(rollup({ external: ['request', 'cheerio'] }))
    .on('error', gutil.log)
    .pipe(babel({ stage: 0 }))
    .pipe(concat('realty-parser.js'))
    .pipe(gulp.dest('lib'));
});

Solution 2:

If you want to get it all in a single file then you will have to write .pipe(gulp.dest("dist/js/jsfile.js")); where jsfile is the name of your file.

Post a Comment for "Gulp Concat And Require Path"