Skip to content

Commit

Permalink
Merge pull request #15 from annexare/es5-umd
Browse files Browse the repository at this point in the history
Add ES5 UMD build
  • Loading branch information
Z-AX authored Oct 6, 2017
2 parents 3baa63d + e360588 commit 9b84db7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
2 changes: 2 additions & 0 deletions dist/index.es5.min.js

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const
NAME = 'Countries',
CONTINENTS = 'continents',
COUNTRIES = 'countries',
LANGUAGES = 'languages',
Expand All @@ -18,9 +19,11 @@ const
DO_DATA = 'data',
DO_EMOJI = 'emoji',
DO_MIN = 'min',
DO_MIN_ES5 = 'es5.min',
DO_MINIMAL = 'minimal',
DO_SQL = 'sql',

JS_EXT = 'js',
JSON_EXT = 'json',
JSON_TAB = 2,
fs = require('fs'),
Expand Down Expand Up @@ -91,6 +94,39 @@ gulp.task(DO_EMOJI, function (callback) {
callback && callback();
});

gulp.task(DO_MIN_ES5, function () {
const babel = require('gulp-babel');
const header = require('gulp-header');
const pkg = require('./package.json');
const uglify = require('gulp-uglify');
const webpack = require('webpack-stream');

const banner = '/*! <%= pkg.name %> v<%= pkg.version %> by Annexare | <%= pkg.license %> */\n';

return gulp.src('dist/index.js')
.pipe(webpack({
output: {
filename: `index.${DO_MIN_ES5}.${JS_EXT}`,
libraryTarget: 'umd',
library: NAME,
umdNamedDefine: true,
},
stats: false
}))
.pipe(babel({
presets: [
['env', {
targets: {
uglify: true
}
}]
]
}))
.pipe(uglify())
.pipe(header(banner, { pkg }))
.pipe(gulp.dest('dist/'));
});

gulp.task(DO_MIN, function (callback) {
fs.writeFileSync(`${DIST}${COUNTRIES}.${DO_MIN}.${JSON_EXT}`, JSON.stringify(countries) + LF);
fs.writeFileSync(`${DIST}${CONTINENTS}.${DO_MIN}.${JSON_EXT}`, JSON.stringify(continents) + LF);
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@
"eslint": "eslint gulpfile.js; exit 0"
},
"devDependencies": {
"eslint": "*",
"gulp": "*",
"punycode": "*"
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.0",
"eslint": "^4.8.0",
"gulp": "^3.9.1",
"gulp-babel": "^7.0.0",
"gulp-header": "^1.8.9",
"gulp-uglify": "^3.0.0",
"punycode": "^2.1.0",
"webpack-stream": "^4.0.0"
},
"devEngines": {
"node": ">=6.0"
Expand Down

0 comments on commit 9b84db7

Please sign in to comment.