I have a simple file:
File main.js
'use strict';
const somefile = require('somefile')
// class MyClass ...
// some js
I want to use Gulp.js to create a minified file that has the code from somefile.js included too. But for some reason, I can't find a way to do this. Inside my minified file I have require('somefile'), not the full code.
File gulpfile.js
const gulp = require('gulp');
const minify = require('gulp-minify');
const babel = require('gulp-babel');
const include = require("gulp-include");
const sourcemaps = require('gulp-sourcemaps');
const jsImport = require('gulp-js-import');
const resolveDependencies = require('gulp-resolve-dependencies');
gulp.task('default', () =>
gulp.src('src/main.js')
.pipe(sourcemaps.init())
.pipe(resolveDependencies({
pattern: /\* @requires [\s-]*(.*\.js)/g
}))
.pipe(jsImport({hideConsole: true}))
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(minify({
ext: {
min: '.min.js'
}
}))
.pipe(gulp.dest('dist'))
);
I've tried with gulp-concat too.
I'm missing something, but not sure what. How can I fix this?