I have a simple file:
main.js:
'use strict';
const somefile = require('somefile')
// class MyClass ...
// some js
I want to use gulp 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.
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.
Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…