-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (52 loc) · 1.26 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
// Styles
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
// Gulp
const gulp = require('gulp');
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const gutil = require('gulp-util');
gulp.task('build:styles', ['sass:compiled']);
// Watch Tasks
gulp.task('watch', () => {
gulp.watch(['src/scss/**/*.scss'], ['sass:compiled']);
});
/**
* Sass Tasks
*/
gulp.task('sass:compiled', () => {
function buildStyles(prod) {
return gulp
.src('src/scss/main.scss')
.pipe(sourcemaps.init())
.pipe(
sass({
outputStyle: prod ? 'compressed' : 'expanded',
}).on('error', sass.logError)
)
.pipe(
autoprefixer({
browsers: ['> 1%', 'last 2 versions'],
})
)
.pipe(
rename(filePath => {
if (filePath.basename === 'main') {
filePath.basename = 'all-styles';
}
if (prod) {
filePath.extname = `.min${filePath.extname}`;
}
})
)
.pipe(
sourcemaps.write('.', {
includeContent: false,
sourceRoot: '../src',
})
)
.pipe(gulp.dest('dist/css'));
}
buildStyles(); // Expanded CSS
buildStyles(true); // Minified CSS
});