gulp-minify-css
says its deprecated,並指向gulp-css-nano作爲其後繼者。爲什麼css-nano(幾乎)不起作用?
爲什麼我用cssnano達到如此之弱的結果?
我做minifything(事後美化了可讀性):
gulp.task('teststyles-nano', [], function() {
gulp.src('css/testcase.css')
.pipe(nano())
.pipe(cssbeautify())
.pipe(rename('nano.css'))
.pipe(gulp.dest('./public/'));
});
gulp.task('teststyles-minify', [], function() {
gulp.src('css/testcase.css')
.pipe(minifyCss()) // resp. .pipe(minifyCss())
.pipe(cssbeautify())
.pipe(rename('minify.css')) // resp. 'minify.css'
.pipe(gulp.dest('./public/'));
});
這裏是我的testcase.css,用大量的故意東西來優化:
html, body {
margin: 0;
padding: 0;
}
h1, h2, h3 {
color: green;
color: purple; /* redundant in place */
background-color: #caa;
}
html, body { /* combine to above, remove duplicates? */
margin: 0;
background-color: #aac;
}
/* group media queries,
remove redundant rules and/or combine p, div */
@media only screen and (max-width: 500px) {
p { background-color: orange; }
}
@media only screen and (max-width: 500px) {
p { background-color: purple; }
div { background-color: purple; }
}
h1, h2, h3, h1, h2 { /* combine to above, remove double selectors */
font-family: 'Helvetica Neue', Helvetica, Arial, Arial, Arial, sans-serif;
font-weight: bold;
color: orange;
text-decoration: underline;
margin-top: 10px; /* screams combining */
margin-right: 20px;
margin-bottom: 10px;
margin-left: 20px;
}
minify.css
有漂亮的很多人都預計,其中nano.css
根本沒有:
我在Windows7,x64下。版本:
npm list --depth=0 | grep -i css
├── [email protected] extraneous
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
因此,我非常無能,在這樣一個孤立的案例。
我不認爲你的問題是爲什麼有人決定在他的業餘時間停止開發一個開源項目,所以我建議你編輯這個問題,並用css nano問一下你的具體問題。 –
** cssnano **不會在旁邊做這項工作 – Muhammed