diff options
Diffstat (limited to 'gulpfile.babel.js')
-rw-r--r-- | gulpfile.babel.js | 22 |
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'; | |||
3 | import babel from 'gulp-babel'; | 3 | import babel from 'gulp-babel'; |
4 | import sass from 'gulp-sass'; | 4 | import sass from 'gulp-sass'; |
5 | import server from 'gulp-server-livereload'; | 5 | import server from 'gulp-server-livereload'; |
6 | import del from 'del'; | ||
7 | import { exec } from 'child_process'; | 6 | import { exec } from 'child_process'; |
8 | import dotenv from 'dotenv'; | 7 | import dotenv from 'dotenv'; |
9 | import sassVariables from 'gulp-sass-variables'; | 8 | import sassVariables from 'gulp-sass-variables'; |
9 | import { removeSync } from 'fs-extra'; | ||
10 | import kebabCase from 'kebab-case'; | ||
11 | import hexRgb from 'hex-rgb'; | ||
10 | 12 | ||
11 | import config from './package.json'; | 13 | import config from './package.json'; |
12 | 14 | ||
15 | import * as rawStyleConfig from './src/theme/default/legacy.js'; | ||
16 | |||
13 | dotenv.config(); | 17 | dotenv.config(); |
14 | 18 | ||
19 | const 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 | |||
15 | const paths = { | 24 | const 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 | ||
52 | const clean = () => del([paths.tmp, paths.dest]); | 61 | const clean = (done) => { |
62 | removeSync(paths.tmp); | ||
63 | removeSync(paths.dest); | ||
64 | |||
65 | done(); | ||
66 | }; | ||
53 | export { clean }; | 67 | export { clean }; |
54 | 68 | ||
55 | export function mvSrc() { | 69 | export function mvSrc() { |
@@ -78,9 +92,9 @@ export function html() { | |||
78 | 92 | ||
79 | export function styles() { | 93 | export 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', |