-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.babel.js
48 lines (40 loc) · 1.28 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
import path from 'path';
import gulp from 'gulp';
import sass from 'gulp-sass';
import concat from 'gulp-concat';
import ejs from 'gulp-ejs';
import glob from 'glob';
import appConst from './src/appConst';
const srcScssPath = glob.sync('src/assets/styles/**/*.scss');
const srcTemplatePath = glob.sync('src/assets/views/*.ejs');
const distPath = 'addon/dist';
const dirCssPath = 'style.css';
const templateRoot = path.resolve(__dirname, 'src/assets/views');
const srcTestTemplatePath = 'tests/fixture/*.ejs';
gulp.task('css', () => {
return gulp
.src(srcScssPath)
.pipe(sass())
.pipe(concat(dirCssPath))
.pipe(gulp.dest(distPath));
});
gulp.task('html', () => {
return gulp
.src(srcTemplatePath)
.pipe(ejs({ appConst }, {}, { ext: '.html' }))
.pipe(gulp.dest(distPath));
});
gulp.task('test:html', () => {
return gulp
.src(srcTestTemplatePath, {
base: './' // output same dir with src dir
})
.pipe(ejs({ appConst, templateRoot }, {}, { ext: '.html' }))
.pipe(gulp.dest('./'));
});
gulp.task('watch', () => {
gulp.watch(srcScssPath, gulp.parallel('css')),
gulp.watch(srcTemplatePath, gulp.parallel('html')),
gulp.watch(srcTestTemplatePath, gulp.parallel('test:html'));
});
gulp.task('default', gulp.parallel('css', 'html', 'test:html'));