【发布时间】:2017-03-02 10:21:57
【问题描述】:
我正在开发一个轻量级的 Wordpress 主题,我想使用所需的 style.css 文件作为我唯一的 CSS 文件。
我的要求是:
- 必须有Wordpressstylesheet header,
- 并且上面的 CSS 代码应该被缩小。
我正在使用 SASS,并使用 gulp-sass 对其进行编译。现在,我正在做:
/* gulpfile.babel.js */
const base = {
src: 'src',
dest: 'my-theme'
};
const routes = {
sass: {
src: `${base.src}/scss/style.scss`,
dest: `${base.dest}/`
}
};
gulp.task('styles', () => {
return gulp.src(routes.sass.src)
.pipe(plumber((err) => {
console.error(err.message);
}))
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest(routes.sass.dest));
});
我的style.scss 包含:
/*
Theme Name: My Theme Name
Theme URI: http://example.com/my-theme
Author: My name
Author URI: http://example.com/
Description: My theme description
Version: 1.0
License: GNU General Public License v3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Tags: custom, lightweight
Text Domain: textdomain
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/
@import 'common';
这可行,但不符合我的第二个要求(缩小的 CSS)。如果我添加
.pipe(sass({outputStyle: 'compressed'}))
然后我失去了标题。我在 gulp-sass 或 node-sass 上找不到任何选项来缩小和保留 /* … */ cmets。
有没有人想出解决办法?
【问题讨论】: