forked from pryley/float-labels.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
126 lines (119 loc) · 2.96 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var args = require( 'yargs' ).argv;
var autoprefixer = require( 'gulp-autoprefixer' );
var browserSync = require( 'browser-sync' ).create();
var bump = require( 'gulp-bump' );
var cssnano = require( 'gulp-cssnano' );
var gulp = require( 'gulp' );
var gulpif = require( 'gulp-if' );
var jshint = require( 'gulp-jshint' );
var moduleImporter = require( 'sass-module-importer' );
var notify = require( 'gulp-notify' );
var pump = require( 'pump' );
var rename = require( 'gulp-rename' );
var sass = require( 'gulp-sass' );
var uglify = require( 'gulp-uglify' );
var watch = require( 'gulp-watch' );
var paths = {
dist: 'dist/',
js : 'src/float-labels.js',
scss: [
'demo/scss/**/*.scss',
'src/float-labels.scss',
],
bump: {
'version': [
'bower.json',
'package.json',
'src/float-labels.js',
'src/float-labels.scss',
],
},
};
/* CSS Task
-------------------------------------------------- */
gulp.task( 'css', function ()
{
pump([
gulp.src( paths.scss, { base: '.' }),
sass({
importer: moduleImporter(),
outputStyle: 'expanded'
}).on( 'error', sass.logError ),
autoprefixer(),
gulpif( args.production, cssnano() ),
rename( function( path ) {
path.dirname = path.dirname.replace( 'src', 'dist' );
path.dirname = path.dirname.replace( 'scss', 'css' );
}),
gulp.dest( '.' ),
browserSync.stream(),
notify({
message: 'CSS Task complete!',
onLast : true
}),
]);
});
/* JSHint Task
-------------------------------------------------- */
gulp.task( 'jshint', function()
{
pump([
gulp.src( paths.js ).
jshint(),
jshint.reporter( 'jshint-stylish' ),
jshint.reporter( 'fail' ),
notify({
message: 'JSHint Task complete!',
onLast : true
}),
]);
});
/* JS Task
-------------------------------------------------- */
gulp.task( 'js', function ()
{
pump([
gulp.src( paths.js ),
gulpif( args.production, uglify({
output: { comments: 'some' },
})),
rename({ suffix: '.min' }),
gulp.dest( paths.dist ),
browserSync.stream(),
notify({
message: 'JS Task complete!',
onLast : true
}),
]);
});
/* Version Task
-------------------------------------------------- */
gulp.task( 'bump', function() {
['patch', 'minor', 'major'].some( function( arg ) {
if( !args[arg] )return;
for( var key in paths.bump ) {
if( !paths.bump.hasOwnProperty( key ))continue;
gulp.src( paths.bump[key], { base: '.' })
.pipe( bump({ type: arg, key: key }))
.pipe( gulp.dest('.'));
}
return true;
});
});
/* Watch Task
-------------------------------------------------- */
gulp.task( 'watch', function ()
{
browserSync.init({
server: { baseDir: '.' }
});
gulp.watch( paths.js, ['js'] );
gulp.watch( paths.scss, ['css'] );
gulp.watch( '*.html' ).on( 'change', browserSync.reload );
});
/* Default Task
-------------------------------------------------- */
gulp.task( 'default', function ()
{
gulp.start( 'css', 'js' );
});