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
|
||||
|
||||
### Dependencies
|
||||
|
||||
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 gulp
|
||||
|
||||
Install:
|
||||
### Install
|
||||
|
||||
npm install
|
||||
bower install
|
||||
|
||||
Build:
|
||||
### Build
|
||||
|
||||
gulp
|
||||
gulp #for release
|
||||
gulp debug #for development
|
||||
|
||||
Develop:
|
||||
### Develop
|
||||
|
||||
gulp watch
|
||||
|
||||
|
|
|
|||
25
gulpfile.js
25
gulpfile.js
|
|
@ -12,12 +12,16 @@ var path = require('path');
|
|||
var cached = require('gulp-cached');
|
||||
var remember = require('gulp-remember');
|
||||
var inject = require('gulp-inject');
|
||||
var gulpif = require('gulp-if');
|
||||
var gutil = require('gulp-util');
|
||||
|
||||
var debug = false;
|
||||
|
||||
var paths = {
|
||||
// see overrides in bower.json
|
||||
scriptsConfig: mainBowerFiles('**/url-search-params/**/*.js'),
|
||||
scripts: mainBowerFiles([
|
||||
'**/*.js',
|
||||
'**/*.js',
|
||||
'!**/*.min.js',
|
||||
'!**/url-search-params/**/*.js'
|
||||
]).concat([
|
||||
|
|
@ -43,10 +47,15 @@ gulp.task('scripts_config', ['clean'], 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: '.' })
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(cached('scripts'))
|
||||
.pipe(uglify())
|
||||
.pipe(cached('scripts'))
|
||||
.pipe(gulpif(!debug, uglify()))
|
||||
.pipe(remember('scripts'))
|
||||
.pipe(concat(paths.destName + '.js'))
|
||||
.pipe(sourcemaps.write('.'))
|
||||
|
|
@ -93,16 +102,17 @@ gulp.task('fonts', ['clean'], function() {
|
|||
|
||||
gulp.task('clean', function(cb) {
|
||||
del(paths.dest + '/**/*' , cb);
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
debug = true;
|
||||
var watcher = gulp.watch(paths.scripts, ['scripts']);
|
||||
watcher.on('change', function (event) {
|
||||
if (event.type === 'deleted') {
|
||||
delete cached.caches.scripts[event.path];
|
||||
remember.forget('scripts', event.path);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('debug', function() {
|
||||
|
|
@ -125,3 +135,8 @@ gulp.task('inject', function () {
|
|||
});
|
||||
|
||||
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-tap": "^0.1.3",
|
||||
"gulp-uglify": "^1.1.0",
|
||||
"gulp-if": "^2.0.0",
|
||||
"gulp-util": "^3.0.7",
|
||||
"main-bower-files": "^2.6.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue