-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathgulpfile.babel.js
104 lines (92 loc) · 2.38 KB
/
gulpfile.babel.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
import yargs from 'yargs';
const isProduction = yargs.argv.prod ? true : false;
import gulp from 'gulp';
import header from 'gulp-header';
import postcss from 'gulp-postcss';
import postcssImport from 'postcss-import';
import postcssMixins from 'postcss-mixins';
import postcssHexrgba from 'postcss-hexrgba';
import postcssNested from 'postcss-nested';
import postcssInlineSvg from 'postcss-inline-svg';
import postcssCalc from 'postcss-calc';
import cssMqpacker from 'css-mqpacker';
import autoprefixer from 'autoprefixer';
import concat from 'gulp-concat';
import uglify from 'gulp-uglify';
import rename from 'gulp-rename';
import cleanCSS from 'gulp-clean-css';
import del from 'del';
const paths = {
styles: {
src: [
'src/resources/pcss/**/*.pcss',
'!src/resources/pcss/**/_*.pcss'
],
dest: 'src/resources/css/'
},
scripts: {
src: [
'src/resources/js/**/*.js',
'!src/resources/js/**/*.min.js',
],
dest: 'src/resources/js/'
}
};
const banner = [
'/**',
' * This CSS file was auto-generated via PostCSS',
' *',
' * Contributors should avoid editing this file, but instead edit the associated',
' * src/resources/pcss/ file. For more information, check out the repository.',
' *',
' * @see: http://github.com/bordoni/fakerpress',
' */',
'',
'',
].join( '\n' );
export const clean = () => del( [ 'src/resources/js/**/*.min.js', 'src/resources/css/**/*.css' ] );
/*
* You can also declare named functions and export them as tasks
*/
export function styles() {
const plugins = [
autoprefixer,
postcssImport,
postcssMixins,
postcssNested,
postcssInlineSvg,
postcssCalc,
postcssHexrgba,
cssMqpacker,
];
return gulp.src( paths.styles.src )
.pipe( postcss( plugins ) )
.pipe( cleanCSS() )
// pass in options to the stream
.pipe( rename( {
suffix: '.min',
extname: '.css'
} ) )
.pipe( gulp.dest( paths.styles.dest ) );
}
export function scripts() {
return gulp.src( paths.scripts.src, { sourcemaps: true } )
.pipe( uglify() )
.pipe( rename( {
suffix: '.min'
} ) )
.pipe( gulp.dest( paths.scripts.dest ) );
}
/*
* You could even use `export as` to rename exported tasks
*/
function watchFiles() {
gulp.watch( paths.scripts.src, scripts );
gulp.watch( paths.styles.src, styles );
}
export { watchFiles as watch };
const build = gulp.series( clean, gulp.parallel( styles, scripts ) );
/*
* Export a default task
*/
export default build;