Skip to content

Commit

Permalink
feat(umd): build will now generate two umd bundles
Browse files Browse the repository at this point in the history
one *.umd.js and a *.umd.min.js as per
comments
  • Loading branch information
izifortune committed Jun 29, 2017
1 parent 17092d6 commit 8d40638
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"gulp": "^3.9.1",
"gulp-rename": "^1.2.2",
"gulp-rollup": "^2.11.0",
"gulp-uglify": "^3.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
Expand All @@ -54,8 +55,8 @@
"node-sass-tilde-importer": "^1.0.0",
"node-watch": "^0.5.2",
"protractor": "~5.1.0",
"pump": "^1.0.2",
"rollup": "^0.41.6",
"rollup-plugin-uglify": "^2.0.1",
"run-sequence": "^1.2.2",
"rxjs": "^5.1.0",
"ts-node": "~2.0.0",
Expand Down
24 changes: 14 additions & 10 deletions generators/app/templates/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ var gulp = require('gulp'),
path = require('path'),
ngc = require('@angular/compiler-cli/src/main').main,
rollup = require('gulp-rollup'),
uglify = require('gulp-uglify'),
pump = require('pump'),
rename = require('gulp-rename'),
del = require('del'),
runSequence = require('run-sequence'),
inlineResources = require('./tools/gulp/inline-resources'),
uglify = require('rollup-plugin-uglify');
inlineResources = require('./tools/gulp/inline-resources');

const rootFolder = path.join(__dirname);
const srcFolder = path.join(rootFolder, 'src');
Expand Down Expand Up @@ -137,19 +138,21 @@ gulp.task('rollup:umd', function () {
// See https://github.com/rollup/rollup/wiki/JavaScript-API#globals
globals: {
typescript: 'ts'
},

// https://github.com/TrySound/rollup-plugin-uglify to uglify the .umd
// For all the options you can have a look at
// https://github.com/mishoo/UglifyJS2#api-reference
plugins: [
uglify()
]
}
}))
.pipe(rename('<%= props.libraryName.kebabCase %>.umd.js'))
.pipe(gulp.dest(distFolder));
});

gulp.task('uglify', function (cb) {
pump([
gulp.src(`${distFolder}/<%= props.libraryName.kebabCase %>.umd.js`),
uglify(),
rename('<%= props.libraryName.kebabCase %>.umd.min.js'),
gulp.dest(distFolder)
], cb);
});

/**
* 7. Copy all the files from /build to /dist, except .js files. We ignore all .js from /build
* because with don't need individual modules anymore, just the Flat ES module generated
Expand Down Expand Up @@ -198,6 +201,7 @@ gulp.task('compile', function () {
'ngc',
'rollup:fesm',
'rollup:umd',
'uglify',
'copy:build',
'copy:manifest',
'copy:readme',
Expand Down

0 comments on commit 8d40638

Please sign in to comment.