forked from NervJS/taro-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (51 loc) · 1.35 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
/* eslint-disable import/no-commonjs */
const glob = require('glob')
const gulp = require('gulp')
const path = require('path')
const fsExtra = require('node-fs-extra')
const gSass = require('gulp-sass')
const gClean = require('gulp-clean')
const gConcat = require('gulp-concat')
const THEME_PATH = path.join('./dist/theme')
const PATTERN = './src/{style,components}/**/*.scss'
const getSassFile = () => {
const filesPath = glob.sync(PATTERN).reverse()
const content = filesPath
.map(item => {
const realPath = path.relative(THEME_PATH, item)
return `@import '${realPath}'; `
})
.join('\n')
return new Promise((resolve, reject) => {
const FILE_PATH = path.join(THEME_PATH, 'default.scss')
fsExtra.outputFile(FILE_PATH, content, err => {
if (err) {
return reject(err)
}
resolve({ sucess: true })
})
})
}
gulp.task('theme', () => {
getSassFile().then(() => {
gulp.src('./src/style/theme/**').pipe(gulp.dest('./dist/theme/'))
})
})
gulp.task('cleanTheme', () => {
gulp
.src('./dist/theme', {
read: false
})
.pipe(gClean())
})
gulp.task('sass', () => {
gulp
.src(['./src/**/*.scss', '!./src/style/theme/*'])
.pipe(
gSass({
outputStyle: 'compressed'
}).on('error', gSass.logError)
)
.pipe(gConcat('main.css'))
.pipe(gulp.dest('./dist/theme'))
})