Skip to content

Instantly share code, notes, and snippets.

@jcyh0120
Created October 26, 2017 02:59
Show Gist options
  • Save jcyh0120/31617bcffbf37016f51f98c2d85fee50 to your computer and use it in GitHub Desktop.
Save jcyh0120/31617bcffbf37016f51f98c2d85fee50 to your computer and use it in GitHub Desktop.
gulp source map with babel, uglifyjs, ngAnnotation.
var gulp = require('gulp');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var sh = require('shelljs');
var sourcemaps = require('gulp-sourcemaps');
var babel = require('gulp-babel');
// new
var del = require('del');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require("gulp-uglify");
var runSequence = require('run-sequence');
var paths = {
dist: ['./www'],
scripts: [
'./src/app/**/*.js'
]
};
var files = {
jsbundle: 'app.bundle.min.js'
};
gulp.task('scripts-sourcemap', function () {
return gulp.src(paths.scripts)
.pipe(sourcemaps.init())
.pipe(ngAnnotate({
remove: true,
add: true,
single_quotes: true
}))
.pipe(babel({
presets: ['es2015']
}))
.pipe(uglify())
.pipe(concat(files.jsbundle))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.dist + '/app'))
.on('error', function (err) {
gutil.log(gutil.colors.red('[Error]'), err.toString());
this.emit('end');
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment