-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
32 lines (29 loc) · 942 Bytes
/
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
const sass = require('gulp-sass');
const gulp = require('gulp');
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const gutil = require('gulp-util');
const autoprefixer = require('gulp-autoprefixer');
gulp.task('watch', () => {
gulp.watch(['src/scss/**/*.scss'], ['sass:compiled']);
});
gulp.task('sass:compiled', () => {
function buildStyles(prod) {
return gulp.src('src/scss/main.scss').pipe(sourcemaps.init()).pipe(sass({
outputStyle: prod ? 'compressed' : 'expanded',
})).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();
buildStyles(true);
});