-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
73 lines (65 loc) · 1.98 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-unresolved */
const path = require('path');
const gulp = require('gulp');
const less = require('gulp-less');
const rename = require('gulp-rename');
const prettier = require('gulp-prettier');
const lessToJs = require('gulp-less-variables-to-file');
const LessAutoprefix = require('less-plugin-autoprefix');
const cssnano = require('gulp-cssnano');
const LessNpmImport = require('less-plugin-npm-import');
const addLessImportInline = require('./scripts/gulp-add-less-inline-import');
const pkg = require('./package.json');
const sourceFile = path.resolve(__dirname, './src/index.less');
// deprecated: 由于存在 hardcode 性质的 override 因此不再提供 less 输出
gulp.task('less', () => {
return gulp
.src(sourceFile)
.pipe(addLessImportInline())
.pipe(less())
.pipe(prettier())
.pipe(rename('theme.less'))
.pipe(gulp.dest('./lib'))
.pipe(lessToJs())
.pipe(rename('theme.js'))
.pipe(prettier())
.pipe(gulp.dest('./lib'));
});
const antdIdeThemeFile = path.resolve(__dirname, './src/antd-ide-theme.less');
gulp.task('theme', () => {
return gulp
.src(antdIdeThemeFile)
.pipe(
less({
javascriptEnabled: true,
plugins: [
new LessNpmImport({ prefix: '~' }),
new LessAutoprefix({ browsers: pkg.browserslist }),
],
}),
)
.pipe(prettier())
.pipe(rename('index.css'))
.pipe(gulp.dest('./lib'))
.pipe(cssnano())
.pipe(rename('index.min.css'))
.pipe(gulp.dest('./lib'));
});
gulp.task('color-theme', () => {
return gulp
.src([
path.resolve(__dirname, './color-theme/light.less'),
path.resolve(__dirname, './color-theme/dark.less'),
])
.pipe(
less({
javascriptEnabled: true,
plugins: [
new LessNpmImport({ prefix: '~' }),
new LessAutoprefix({ browsers: pkg.browserslist }),
],
}),
)
.pipe(gulp.dest('./_site'));
});