I am writing the typescript code and want to convert into .min.js file,
After the conversion is getting exports and require an undefined exception. if I will use the latest gulp commands am getting a module exception because am using old node js, because our product using nodejs 6
how to convert the .js.map file and minify to a single file
gulpfile.js
var path = require('path');
var ts = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
const gulp = require('gulp');
const concat = require('gulp-concat');
const jshint = require('gulp-jshint');
let babel = require('gulp-babel');
const map = require('map-stream');
const del = require('del');
const uglify = require('gulp-uglify');
const jasmine = require('gulp-jasmine');
var debug = require("gulp-debug");
var config = {
src: './Scripts',
dest: './build',
};
gulp.task('build-sources', function () {
return gulp.src(path.join(config.src, '/**/*.ts'))
// .pipe(sourcemaps.init())
.pipe(ts.createProject('./tsconfig.json')())
// .pipe(sourcemaps.write())
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(uglify())
.pipe(concat('bundle.js'))
.pipe(gulp.dest('build/app/'))
});
gulp.task('css', function () {
return gulp.src(['styles/css/**.*'])
.pipe(gulp.dest('build/css/'))
});
gulp.task('images', function () {
return gulp.src(['styles/images/*'])
.pipe(gulp.dest('build/images/'))
});
gulp.task('libs', function () {
return gulp.src(['styles/libs/*'])
.pipe(gulp.dest('build/libs/'))
});
gulp.task('lint', function () {
const jshintTotals = jshintTotalReporter();
return gulp.src(sourceCode)
.pipe(jshint('.jshintrc'))
.pipe(jshint.r`enter code here`eporter('jshint-stylish'))
.pipe(jshintTotals.collect)
.on('end', jshintTotals.report);
});
gulp.task('test', () =>
gulp.src([testCasesPath])
// gulp-jasmine works on filepaths so you can't have any plugins before it
.pipe(jasmine())
);
gulp.task('clean', function () {
return del([
'build/app/',
'build/css/',
'build/images/',
'build/libs/',
]);
});
//gulp.task('default', gulp.series('ts'));
//gulp.task('clean', gulp.series('clean'));
gulp.task('build', gulp.series('build-sources'));
//gulp.task('run_Prod_Build', gulp.series('clean', 'css','libs', 'images', 'prod_env_js'));
//gulp.task('run_dev', gulp.series('clean', 'css', 'images','libs', 'dev_env_js'));