-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
64 lines (53 loc) · 1.68 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
process.env.UV_THREADPOOL_SIZE = 100; // fix a bug in libsass
var gulp = require( 'gulp' );
var sass = require( 'gulp-sass' );
var autoprefixer = require( 'gulp-autoprefixer' );
var sourcemaps = require( 'gulp-sourcemaps' );
var childProcess = require( 'child_process' );
function doSass() {
if ( arguments.length ) {
console.log( 'Sass file ' + arguments[0].path + ' changed.' );
}
var start = new Date();
console.log( 'Building CSS bundle' );
gulp.src( './scss/welcome-panel.scss' )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( autoprefixer() )
.pipe( sourcemaps.write( '.' ) )
.pipe( gulp.dest( './css' ) )
.on( 'end', function() {
console.log( 'CSS finished.' );
} );
};
gulp.task( 'sass:build', function() {
doSass();
} );
gulp.task( 'sass:watch', function() {
doSass();
gulp.watch( [ './**/*.scss' ], doSass );
} );
gulp.task( 'webpack:build', function( cb ) {
var env = process.env.NODE_ENV;
var command = ( 'undefined' !== env && 'production' === 'env' )
? 'webpack --color'
: 'webpack -p --color';
childProcess.exec( command, function( err, stdout, stderr ) {
console.log( stdout );
console.log( stderr );
cb( err );
} );
} );
gulp.task( 'webpack:watch', ( cb ) => {
const webpack_watch = childProcess.spawn( 'webpack', [ '--watch', '--color' ] );
webpack_watch.stdout.on( 'data', ( data ) => {
console.log( `stdout: ${data}` );
} );
webpack_watch.stderr.on( 'data', ( data ) => {
console.log( `stderr: ${data}` );
} );
webpack_watch.on( 'close', ( code ) => {
console.log( `child process exited with code ${code}` );
} );
} );
gulp.task( 'default', [ 'sass:build', 'webpack:build' ] );
gulp.task( 'watch', [ 'sass:watch', 'webpack:watch' ] );