-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
36 lines (31 loc) · 1.03 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
const cssnano = require('gulp-cssnano')
const connect = require('gulp-connect-php')
const { dest, parallel, src, task, watch } = require('gulp')
const rename = require('gulp-rename')
const sass = require('gulp-dart-sass')
const sourcemaps = require('gulp-sourcemaps')
const stripComments = require('gulp-strip-css-comments')
const compileSass = (file) => {
console.log(file)
return src(file)
.pipe(sass().on('error', (error) => console.log(error)))
.pipe(sourcemaps.init())
.pipe(stripComments())
.pipe(cssnano())
.pipe(rename({ extname: '.css' }))
.pipe(sourcemaps.write('.'))
.pipe(dest((file) => file.base))
}
task('startServer', () => connect.server())
task('watchApplicationSass', () =>
watch(['./app/assets/stylesheets/**/*.scss']).on('change', () =>
compileSass('app/assets/stylesheets/application.scss')
)
)
task('watchPagesSass', () =>
watch(['./app/pages/**/*.scss']).on('change', (file) => compileSass(file))
)
task(
'default',
parallel('startServer', 'watchApplicationSass', 'watchPagesSass')
)