aboutsummaryrefslogtreecommitdiffstats
path: root/gulpfile.babel.js
diff options
context:
space:
mode:
Diffstat (limited to 'gulpfile.babel.js')
-rw-r--r--gulpfile.babel.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 95b026f66..cea42d6c9 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -3,15 +3,24 @@ import gulp from 'gulp';
3import babel from 'gulp-babel'; 3import babel from 'gulp-babel';
4import sass from 'gulp-sass'; 4import sass from 'gulp-sass';
5import server from 'gulp-server-livereload'; 5import server from 'gulp-server-livereload';
6import del from 'del';
7import { exec } from 'child_process'; 6import { exec } from 'child_process';
8import dotenv from 'dotenv'; 7import dotenv from 'dotenv';
9import sassVariables from 'gulp-sass-variables'; 8import sassVariables from 'gulp-sass-variables';
9import { removeSync } from 'fs-extra';
10import kebabCase from 'kebab-case';
11import hexRgb from 'hex-rgb';
10 12
11import config from './package.json'; 13import config from './package.json';
12 14
15import * as rawStyleConfig from './src/theme/default/legacy.js';
16
13dotenv.config(); 17dotenv.config();
14 18
19const styleConfig = Object.keys(rawStyleConfig).map((key) => {
20 const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]);
21 return ({ [`$raw_${kebabCase(key)}`]: isHex ? hexRgb(rawStyleConfig[key], { format: 'array' }).splice(0, 3).join(',') : rawStyleConfig[key] });
22});
23
15const paths = { 24const paths = {
16 src: 'src', 25 src: 'src',
17 dest: 'build', 26 dest: 'build',
@@ -49,7 +58,12 @@ function _shell(cmd, cb) {
49 }); 58 });
50} 59}
51 60
52const clean = () => del([paths.tmp, paths.dest]); 61const clean = (done) => {
62 removeSync(paths.tmp);
63 removeSync(paths.dest);
64
65 done();
66};
53export { clean }; 67export { clean };
54 68
55export function mvSrc() { 69export function mvSrc() {
@@ -78,9 +92,9 @@ export function html() {
78 92
79export function styles() { 93export function styles() {
80 return gulp.src(paths.styles.src) 94 return gulp.src(paths.styles.src)
81 .pipe(sassVariables({ 95 .pipe(sassVariables(Object.assign({
82 $env: process.env.NODE_ENV === 'development' ? 'development' : 'production', 96 $env: process.env.NODE_ENV === 'development' ? 'development' : 'production',
83 })) 97 }, ...styleConfig)))
84 .pipe(sass({ 98 .pipe(sass({
85 includePaths: [ 99 includePaths: [
86 './node_modules', 100 './node_modules',