Skip to content

Commit

Permalink
Some simplifications in the build file
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Feb 28, 2015
1 parent d993917 commit 514f015
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@ var mkdirp = require('mkdirp');
var webpack = require('webpack');
var uglify = require('uglify-js');

var ENTRY = './src/js/JSONEditor.js';
var HEADER = './src/js/header.js';
var IMAGE = './src/css/img/jsoneditor-icons.png';
var DIST = './dist';
var FILE = 'jsoneditor.js';
var FILE_MAP = 'jsoneditor.map';
var FILE_CSS = 'jsoneditor.css';
var FILE_MIN_CSS = 'jsoneditor.min.css';
var JSONEDITOR_JS = DIST + '/' + FILE;
var JSONEDITOR_MIN_JS = DIST + '/jsoneditor.min.js';
var JSONEDITOR_MAP_JS = DIST + '/' + FILE_MAP;
var JSONEDITOR_CSS = DIST + '/jsoneditor.css';
var JSONEDITOR_MIN_CSS = DIST + '/jsoneditor.min.css';
var NAME = 'jsoneditor';
var ENTRY = './src/js/JSONEditor.js';
var HEADER = './src/js/header.js';
var IMAGE = './src/css/img/jsoneditor-icons.png';
var DIST = './dist';

// generate banner with today's date and correct version
function createBanner() {
Expand All @@ -43,14 +35,14 @@ var webpackConfig = {
library: 'JSONEditor',
libraryTarget: 'umd',
path: DIST,
filename: FILE
filename: NAME + '.js'
},
plugins: [ bannerPlugin ],
cache: true
};

var uglifyConfig = {
outSourceMap: FILE_MAP,
outSourceMap: NAME + '.map',
output: {
comments: /@license/
}
Expand All @@ -75,7 +67,7 @@ gulp.task('bundle', ['mkdir'], function (done) {
gutil.log(err);
}

gutil.log('bundled ' + JSONEDITOR_JS);
gutil.log('bundled ' + NAME + '.js');

done();
});
Expand All @@ -89,14 +81,14 @@ gulp.task('bundle-css', ['mkdir'], function () {
'src/css/menu.css',
'src/css/searchbox.css'
])
.pipe(concatCss(FILE_CSS))
.pipe(concatCss(NAME + '.css'))
.pipe(gulp.dest(DIST))
.pipe(concatCss(FILE_MIN_CSS))
.pipe(concatCss(NAME + '.min.css'))
.pipe(minifyCSS())
.pipe(gulp.dest(DIST));

gutil.log('bundled ' + JSONEDITOR_CSS);
gutil.log('bundled ' + JSONEDITOR_MIN_CSS);
gutil.log('bundled ' + DIST + '/' + NAME + '.css');
gutil.log('bundled ' + DIST + '/' + NAME + '.min.css');
});

// create a folder img and copy the icons
Expand All @@ -107,13 +99,16 @@ gulp.task('copy-img', ['mkdir'], function () {
});

gulp.task('minify', ['bundle'], function () {
var result = uglify.minify([JSONEDITOR_JS], uglifyConfig);
var result = uglify.minify([DIST + '/' + NAME + '.js'], uglifyConfig);

fs.writeFileSync(JSONEDITOR_MIN_JS, result.code);
fs.writeFileSync(JSONEDITOR_MAP_JS, result.map);
var fileMin = DIST + '/' + NAME + '.min.js';
var fileMap = DIST + '/' + NAME + '.map';

gutil.log('Minified ' + JSONEDITOR_MIN_JS);
gutil.log('Mapped ' + JSONEDITOR_MAP_JS);
fs.writeFileSync(fileMin, result.code);
fs.writeFileSync(fileMap, result.map);

gutil.log('Minified ' + fileMin);
gutil.log('Mapped ' + fileMap);

});

Expand Down

0 comments on commit 514f015

Please sign in to comment.