-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (56 loc) · 1.91 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
const gulp = require( 'gulp' ),
browserify = require( 'browserify' ),
buffer = require( 'vinyl-buffer' ),
clean = require( 'gulp-clean-css' ),
rename = require( 'gulp-rename' ),
sass = require( 'gulp-dart-sass' ),
source = require( 'vinyl-source-stream' ),
uglify = require( 'gulp-uglify' );
/**
* Javascript build tasks.
*/
// Front-end.
function jsFrontendTask() {
return browserify( { entries: [ 'color-palette/source/scripts-frontend.js' ] } )
.transform( 'babelify', { presets: [ '@babel/preset-env' ] } )
.bundle()
.pipe( source( 'color-palette-frontend.min.js' ) )
.pipe( buffer() )
.pipe( uglify() )
.pipe( gulp.dest( 'color-palette/build' ) );
}
// Editor.
function jsEditorTask() {
return browserify( { entries: [ 'color-palette/source/scripts-editor.js' ] } )
.transform( 'babelify', { presets: [ '@babel/preset-env', '@babel/preset-react' ] } )
.bundle()
.pipe( source( 'color-palette.min.js' ) )
.pipe( buffer() )
.pipe( uglify() )
.pipe( gulp.dest( 'color-palette/build' ) );
}
/**
* CSS build tasks.
*/
// Front-end.
function cssFrontendTask() {
return gulp.src( 'color-palette/source/styles-frontend.scss' )
.pipe( sass({ outputStyle: 'compressed' }) )
.pipe( clean() )
.pipe( rename( {suffix: '.min'} ) )
.pipe( gulp.dest( 'color-palette/build' ) );
}
// Editor.
function cssEditorTask() {
return gulp.src( 'color-palette/source/styles-editor.scss' )
.pipe( sass({ outputStyle: 'compressed' }) )
.pipe( clean() )
.pipe( rename( {suffix: '.min'} ) )
.pipe( gulp.dest( 'color-palette/build' ) );
}
/**
* Task definitions.
*/
gulp.task( 'default', gulp.series( jsFrontendTask, jsEditorTask, cssFrontendTask, cssEditorTask ) );
gulp.task( 'js', gulp.series( jsFrontendTask, jsEditorTask ) );
gulp.task( 'css', gulp.series( cssFrontendTask, cssEditorTask ) );