Skip to content

Commit 6943136

Browse files
committed
将 CSS 压缩提取
1 parent 449b9ac commit 6943136

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

_tasks/TaskBuildDist.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ module.exports = function (gulp, config) {
7474
return gulp.src(paths.src.less)
7575
.pipe(less())
7676
.pipe(lazyImageCSS({imagePath: lazyDir}))
77-
.pipe(minifyCSS({
78-
safe: true,
79-
reduceTransforms: false,
80-
advanced: false,
81-
compatibility: 'ie7',
82-
keepSpecialComments: 0
83-
}))
8477
.pipe(tmtsprite({margin: 4}))
8578
.pipe(gulpif('*.png', gulp.dest(paths.dist.sprite), gulp.dest(paths.dist.css)));
8679
}
@@ -92,6 +85,19 @@ module.exports = function (gulp, config) {
9285
.pipe(gulp.dest('./dist/css/'));
9386
}
9487

88+
//CSS 压缩
89+
function miniCSS(){
90+
return gulp.src('./dist/css/style-*.css')
91+
.pipe(minifyCSS({
92+
safe: true,
93+
reduceTransforms: false,
94+
advanced: false,
95+
compatibility: 'ie7',
96+
keepSpecialComments: 0
97+
}))
98+
.pipe(gulp.dest('./dist/css/'));
99+
}
100+
95101
//图片压缩
96102
function imageminImg() {
97103
return gulp.src(paths.src.img)
@@ -184,6 +190,7 @@ module.exports = function (gulp, config) {
184190
delDist,
185191
compileLess,
186192
compileAutoprefixer,
193+
miniCSS,
187194
gulp.parallel(
188195
imageminImg,
189196
imageminSprite,

0 commit comments

Comments
 (0)