forked from louisnovick/Materialize-gulp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (47 loc) · 1.87 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var striplog = require('gulp-strip-debug');
var minifycss = require('gulp-minify-css');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var notify = require("gulp-notify");
var connect = require('gulp-connect');
//js files
gulp.task('scripts', function() {
var js_src = 'assets/js/**/*.js';
var js_dest = 'assets/build/js';
// pipe the js through concat, console log stripping, uglification and then store
return gulp.src(js_src)
.pipe(concat('app.min.js')) // concat all files in the src
.pipe(striplog())
.pipe(uglify()) // uglify them all
.pipe(gulp.dest(js_dest)) // save the file
.on('error', gutil.log);
});
gulp.task('css', function() {
return gulp.src(['assets/scss/**/*.scss', 'assets/css/**/*.css'])
.pipe(sass({style: 'compressed', errLogToConsole: true})) // Compile sass
.pipe(concat('app.min.css')) // Concat all css
.pipe(minifycss()) // Minify the CSS
.pipe(gulp.dest('assets/build/css/')) // Set the destination to assets/css
});
// Clean all builds
gulp.task('clean', function() {
return gulp.src(['assets/build/'], {read: false})
.pipe(clean());
});
// web server
gulp.task('webserver', function() {
connect.server();
});
// Default task - clean the build dir
// Then rebuild the js and css files
gulp.task('watch', function(){
gulp.watch(['assets/scss/**/*.scss','assets/css/**/*.css'], ['css']); // Watch and run sass on changes
gulp.watch('assets/js/**/*.js', ['scripts']); // Watch and run javascripts on changes
gulp.src('assets/*')
.pipe(notify('An asset has changed'));
});
gulp.task('default', ['webserver', 'clean', 'css', 'scripts', 'watch']);