-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
77 lines (63 loc) · 2.72 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*===================================================================================================================
* Here, the script need *nodeJS* and *gulp* to run.
*
* This script is for building bowerder from its partials sources; For that, the following operations can be done:
* watching partials sources to biuld the library depending of changes.
* minifications and generate sourcemap when needed.
*===================================================================================================================
* @license MIT
* @author [Tindo N. Arsel](mailto:[email protected])
*/
if (process.versions.node <= '0.12.0') {
console.warn('bowerder-gulp: recommand node version 0.12.x or later ');
require('es6-promise').polyfill();
}
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
notify = require("gulp-notify");
var paths = {
sources: 'src/*.js',
loader: 'src/loader.js',
loaderTest: 'tests/weblibs/bowerder/src',
manager: 'src/manager.js',
bower: 'tests/bower_components',
node: 'node_modules',
destMap: './',
dest: './dist'
};
gulp.task('minify', function () {
// compile and minify all target js files.
// with sourcemaps all the way down
return gulp.src( paths.loader )
.pipe( sourcemaps.init())
.pipe( uglify() )
.pipe( rename({suffix: '.min'}))
.pipe( sourcemaps.write( paths.destMap ))
.pipe( gulp.dest( paths.dest ))
.pipe( notify({ onLast: true, title: 'bowerder-minify:', message: 'minification task complete!' }));
});
// library's builder task
gulp.task('build', ['minify'] );
gulp.task('sync-loader-dev', function () {
return gulp.src( paths.loader )
.pipe( gulp.dest( paths.loaderTest ) )
.pipe( notify({ title: 'bowerder-sync:', message: 'dev loader.js is now synchronized with loader.js using for test!' }) );
});
// run associated task(s) when a file change from given path
gulp.task('watch', function () {
gulp.watch( paths.sources, ['build']);
gulp.watch( paths.loader, ['sync-loader-dev']);
console.log('bowerder-watch: dev-source files are being watched!');
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['watch'], function () {
console.log('.....\n bowerder-dev: available task:');
console.log('watch [default] - (watch source files and automate building / tests)');
console.log('standard - (check standard style code guideline)');
console.log('minify - (uglify and minify js files from sources)');
console.log('sync-loader-dev - (synchronize dev loader.js with loader.js using for test!)');
console.log('build - (build the project)');
console.log('.....');
});