-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
133 lines (116 loc) · 3.45 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const { src, dest, series, parallel, watch } = require('gulp')
const del = require('delete')
const less = require('gulp-less')
const sass = require('gulp-sass')
const cssmin = require('gulp-csso')
const rename = require('gulp-rename')
const sourcemaps = require('gulp-sourcemaps')
const postcss = require('gulp-postcss')
const autoprefixer = require('autoprefixer')
const gulpStylelint = require('gulp-stylelint')
const readConfig = require('read-config')
const svgSprite = require('gulp-svg-sprite')
const standard = require('gulp-standard')
// const pug = require('gulp-pug');
// const concat = require('gulp-concat');
sass.compiler = require('node-sass')
var svgSpriteConfig = readConfig('src/ui/icons/default.config.yml')
function cleanpublic (cb) {
del(['public'], cb)
}
function cleansrc (cb) {
del(['src/ui/**/*.map'], cb)
}
function copyvendors () {
return src([
'./node_modules/svgxuse/*.{js,md}'
], { base: 'node_modules' })
.pipe(dest('./public/ui/'))
}
// function html() {
// return src('client/templates/*.pug')
// .pipe(pug())
// .pipe(dest('build/html'))
// }
function renderless () {
return src('src/ui/**/*.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write('.'))
.pipe(dest('src/ui'))
}
function renderscss () {
return src('src/ui/**/*.scss', 'src/ui/**/*.sass')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('.'))
.pipe(dest('src/ui'))
}
function csspost () {
var plugins = [
autoprefixer()
]
return src(['src/ui/**/*.css', '!src/ui/**/*.min.css'])
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(postcss(plugins))
.pipe(cssmin())
.pipe(rename({ extname: '.min.css' }))
.pipe(sourcemaps.write('.'))
.pipe(dest('public/ui'))
}
function lintcss () {
return src('src/ui/**/*.less')
.pipe(gulpStylelint({
failAfterError: false,
reportOutputDir: './reports/stylelint',
reporters: [
{ formatter: 'verbose', console: true },
{ formatter: 'json', save: 'report.json' }
]
}))
}
function lintjs () {
return src(['src/ui/**/*.js', '*.js'])
.pipe(standard())
.pipe(standard.reporter('default', {
breakOnError: false,
quiet: true
}))
}
function createsvgsprite () {
return src('**/*.svg', { cwd: 'src/ui/icons' })
.pipe(svgSprite(svgSpriteConfig))
.pipe(dest('public/ui/icons'))
}
// function js() {
// return src('client/javascript/*.js', { sourcemaps: true })
// .pipe(concat('app.min.js'))
// .pipe(dest('build/js', { sourcemaps: true }))
// }
function watchsrc () {
watch(['src/ui/**/*.less'], series(renderless, csspost))
watch(['src/ui/**/*.scss', 'src/ui/**/*.sass'], series(renderscss, csspost))
}
// chaining tasks
const clean = parallel(cleanpublic, cleansrc)
const assets = parallel(createsvgsprite, copyvendors)
const rendercss = parallel(renderless, renderscss)
const build = series(clean, rendercss, csspost, cleansrc, assets)
const checks = series(lintcss)
exports.cleanpublic = cleanpublic
exports.cleansrc = cleansrc
exports.copyvendors = copyvendors
// exports.js = js;
exports.renderless = renderless
exports.renderscss = renderscss
exports.csspost = csspost
exports.lintcss = lintcss
exports.lintjs = lintjs
exports.createsvgsprite = createsvgsprite
// exports.html = html;
exports.watchsrc = watchsrc
exports.build = build
exports.clean = clean
exports.dev = series(build, watchsrc)
exports.checks = checks
exports.default = build