-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (61 loc) · 2.02 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
/**
* The purpose of this Gulp File is to compile all the SASS into a CSS master
* sheet, and all the JavaScript files into a single uglified JavaScript file.
*
* @author Kerick Howlett
* @since January 23, 2017
*
* @see https://css-tricks.com/gulp-for-beginners/
* @see https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md
* @see https://github.com/gulpjs/gulp/blob/master/docs/API.md
* @see https://github.com/osscafe/gulp-cheatsheet
*
**/
( function() {
'use strict'; // Establish "Strict Mode".
/* Dependencies. */
const gulp = require( 'gulp' );
const sass = require( 'gulp-sass' );
const minifyCss = require( 'gulp-minify-css' );
const rename = require( 'gulp-rename' );
const concat = require( 'gulp-concat' );
const uglify = require( 'gulp-uglify' );
/* Filepath Locations for Watch Tasks. */
const paths = {
sass: [ './library/scss/**/*.scss' ],
scripts: [ './library/js/**/*.js' ]
};
/* Default task to compile both SASS and JavaScript. */
gulp.task( 'default', ['sass', 'script'] );
/* Compiling SASS to produce minified CSS Master Sheet. */
gulp.task( 'sass', function( done ) {
gulp.src( './library/scss/portfolio.app.scss' )
.pipe( sass( {
errLogToConsole: true
} ) )
.pipe( gulp.dest( './library/dist/' ) )
.pipe( minifyCss( {
keepSpecialComments: 0
} ) )
.pipe( rename( { extname: '.min.css' } ) )
.pipe( gulp.dest( './library/dist/' ) )
.on( 'end', done );
} );
/* Compiling JavaScript to produce primary uglified JavaScript file. */
gulp.task( 'script', function( done ) {
gulp.src( './library/js/**/*' )
.pipe( concat( 'script.min.js' ) )
.pipe( uglify() )
.pipe( gulp.dest( './library/dist/' ) )
.on( 'end', done );
} );
/**
* Watches file paths for any changes so that the browser will automatically
* rebuild the master style sheet and the uglified script when a file change
* has been detected.
**/
gulp.task( 'watch', function() {
gulp.watch( paths.sass, [ 'sass' ] );
gulp.watch( paths.scripts, [ 'script' ] );
} );
} )();