-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
49 lines (44 loc) · 1.48 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
'use strict';
const gulp = require('gulp');
const gulpSass = require('gulp-sass');
const gulpCleanCSS = require('gulp-clean-css');
const gulpRename = require('gulp-rename');
const path = require('path');
const _distDemoPath = 'demo/src/assets/css';
const scssOptions = {
includePaths: [`${__dirname}/node_modules`],
importer: function (url, prev, done) {
// url is the path in import as is, which LibSass encountered.
// prev is the previously resolved path.
// done is an optional callback, either consume it or return value synchronously.
// this.options contains this options hash, this.callback contains the node-style callback
if (url.includes('~')) {
const file = path.join(__dirname, 'node_modules/') + url.slice(1);
return {
file: file
};
} else {
return {
file: url
};
}
},
};
gulp.task('build-theme', function () {
let _themePath = './src/styles/themes/*.scss';
return gulp.src(_themePath)
.pipe(gulpSass.sync(scssOptions).on('error', gulpSass.logError))
.pipe(gulpCleanCSS())
.pipe(gulpRename(function (path) {
path.basename += ".min";
return path;
}))
.pipe(gulp.dest(_distDemoPath));
});
gulp.task('build-theme:watch', function () {
var watches = [
'src/**/styles/*.scss',
'src/styles/**/**.*'
];
gulp.watch(watches, ['build-theme']);
});