-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
77 lines (69 loc) · 1.79 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
71
72
73
74
75
76
77
// Plugins
const gulp = require('gulp'),
sassVariables = require('gulp-sass-variables'),
sass = require('gulp-sass'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
cssnano = require('cssnano'),
rename = require('gulp-rename');
sass.compiler = require('node-sass');
// Define Folders
const paths = {
src : 'src/**/*.scss',
dist: 'dist/',
};
/**
* Compile styles from SCSS to CSS in
*/
function buildShortVersion() {
return gulp.src(paths.src)
.pipe(sassVariables({
$naming: 'short'
}))
.pipe(sass().on('error', sass.logError))
.pipe(postcss([ autoprefixer() ]))
.pipe(gulp.dest(paths.dist))
.pipe(rename({ suffix: '.min' }))
.pipe(postcss([ cssnano() ]))
.pipe(gulp.dest(paths.dist));
}
/**
* Compile styles from SCSS to CSS in
*/
function buildFullVersion() {
return gulp.src(paths.src)
.pipe(sassVariables({
$naming: 'full'
}))
.pipe(sass().on('error', sass.logError))
.pipe(postcss([ autoprefixer() ]))
.pipe(rename({ suffix: '-full' }))
.pipe(gulp.dest(paths.dist))
.pipe(rename({ suffix: '.min' }))
.pipe(postcss([ cssnano() ]))
.pipe(gulp.dest(paths.dist));
}
/**
* Define tasks
*/
gulp.task('buildShortVersion', buildShortVersion);
gulp.task('buildFullVersion', buildFullVersion);
/**
* Build CSS files
*/
function build() {
return gulp.series('buildShortVersion', 'buildFullVersion');
}
/**
* Default watch function
*/
function watch() {
gulp.watch(paths.src, buildShortVersion);
gulp.watch(paths.src, buildFullVersion);
}
/**
* Exports
*/
exports.watch = watch;
exports.build = build;
exports.default = build;