gulp: don't uglify in debug mode
This commit is contained in:
parent
3dee209b4a
commit
86b7bc186c
3 changed files with 29 additions and 9 deletions
11
README.md
11
README.md
|
|
@ -60,21 +60,24 @@ This is needed for pre-loading the selected profile (unless you allowed local fi
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
Requires [Node and npm](http://nodejs.org/) (or [io.js](https://iojs.org)), [Bower](http://bower.io/) and [Gulp](http://gulpjs.com/):
|
Requires [Node and npm](http://nodejs.org/) (or [io.js](https://iojs.org)), [Bower](http://bower.io/) and [Gulp](http://gulpjs.com/):
|
||||||
|
|
||||||
npm install -g bower
|
npm install -g bower
|
||||||
npm install -g gulp
|
npm install -g gulp
|
||||||
|
|
||||||
Install:
|
### Install
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
bower install
|
bower install
|
||||||
|
|
||||||
Build:
|
### Build
|
||||||
|
|
||||||
gulp
|
gulp #for release
|
||||||
|
gulp debug #for development
|
||||||
|
|
||||||
Develop:
|
### Develop
|
||||||
|
|
||||||
gulp watch
|
gulp watch
|
||||||
|
|
||||||
|
|
|
||||||
17
gulpfile.js
17
gulpfile.js
|
|
@ -12,6 +12,10 @@ var path = require('path');
|
||||||
var cached = require('gulp-cached');
|
var cached = require('gulp-cached');
|
||||||
var remember = require('gulp-remember');
|
var remember = require('gulp-remember');
|
||||||
var inject = require('gulp-inject');
|
var inject = require('gulp-inject');
|
||||||
|
var gulpif = require('gulp-if');
|
||||||
|
var gutil = require('gulp-util');
|
||||||
|
|
||||||
|
var debug = false;
|
||||||
|
|
||||||
var paths = {
|
var paths = {
|
||||||
// see overrides in bower.json
|
// see overrides in bower.json
|
||||||
|
|
@ -43,10 +47,15 @@ gulp.task('scripts_config', ['clean'], function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('scripts', function() {
|
gulp.task('scripts', function() {
|
||||||
|
if (debug)
|
||||||
|
gutil.log( gutil.colors.yellow('Running in Debug mode') );
|
||||||
|
else
|
||||||
|
gutil.log( gutil.colors.green('Running in Release mode') );
|
||||||
|
|
||||||
return gulp.src(paths.scripts, { base: '.' })
|
return gulp.src(paths.scripts, { base: '.' })
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(cached('scripts'))
|
.pipe(cached('scripts'))
|
||||||
.pipe(uglify())
|
.pipe(gulpif(!debug, uglify()))
|
||||||
.pipe(remember('scripts'))
|
.pipe(remember('scripts'))
|
||||||
.pipe(concat(paths.destName + '.js'))
|
.pipe(concat(paths.destName + '.js'))
|
||||||
.pipe(sourcemaps.write('.'))
|
.pipe(sourcemaps.write('.'))
|
||||||
|
|
@ -96,6 +105,7 @@ gulp.task('clean', function(cb) {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('watch', function() {
|
gulp.task('watch', function() {
|
||||||
|
debug = true;
|
||||||
var watcher = gulp.watch(paths.scripts, ['scripts']);
|
var watcher = gulp.watch(paths.scripts, ['scripts']);
|
||||||
watcher.on('change', function (event) {
|
watcher.on('change', function (event) {
|
||||||
if (event.type === 'deleted') {
|
if (event.type === 'deleted') {
|
||||||
|
|
@ -125,3 +135,8 @@ gulp.task('inject', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', ['clean', 'scripts_config', 'scripts', 'styles', 'images', 'fonts']);
|
gulp.task('default', ['clean', 'scripts_config', 'scripts', 'styles', 'images', 'fonts']);
|
||||||
|
|
||||||
|
gulp.task('debug', function() {
|
||||||
|
debug = true;
|
||||||
|
gulp.start('default');
|
||||||
|
});
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
"gulp-sourcemaps": "^1.5.1",
|
"gulp-sourcemaps": "^1.5.1",
|
||||||
"gulp-tap": "^0.1.3",
|
"gulp-tap": "^0.1.3",
|
||||||
"gulp-uglify": "^1.1.0",
|
"gulp-uglify": "^1.1.0",
|
||||||
|
"gulp-if": "^2.0.0",
|
||||||
|
"gulp-util": "^3.0.7",
|
||||||
"main-bower-files": "^2.6.2"
|
"main-bower-files": "^2.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue