Merge pull request #58 from bagage/feature/gulp

New gulp debug task and watch CSS folder
This commit is contained in:
Norbert Renner 2016-11-30 22:44:01 +01:00 committed by GitHub
commit 753c36bc70
3 changed files with 30 additions and 9 deletions

View file

@ -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

View file

@ -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') {
@ -103,6 +113,7 @@ gulp.task('watch', function() {
remember.forget('scripts', event.path); remember.forget('scripts', event.path);
} }
}); });
gulp.watch(paths.styles, ['styles']);
}); });
gulp.task('debug', function() { gulp.task('debug', function() {
@ -125,3 +136,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');
});

View file

@ -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"
} }
} }