使用 Gulp 从 package.json 创建 WordPress style.css
Creating a WordPress style.css from package.json with Gulp
我是 Gulp 的新手,但我正在使用它来管理创建 WordPress 主题的构建过程。我的 package.json 设置得很好,我希望我的 style.css 能够反映 package.json。例如,如果我在 package.json 中将我的 version
设置为 0.0.2
,style.css 应该反映在 运行 我的构建任务之后。
再举个例子,如果我把这个作为我的 package.json:
{
"name": "new-site",
"description": "A basic framework for a WordPress template",
"version": "0.0.1",
"repository": "https://github.com/revxx14/new-site",
"license": "MIT"
}
这将是我的 style.css,在 运行 gulp build
之后:
/*
Theme Name: new-site
Theme URI: https://github.com/revxx14/new-site
Description: A basic framework for a WordPress template
Version: 0.0.1
License: MIT
*/
我已经安装了 json-file
软件包,因为我正在使用 gulp-file-include
包含来自 package.json 的版本号以用于缓存清除目的。
您可以在此处查看我的整个 gulpfile:https://github.com/revxx14/new-site/blob/master/gulpfile.js
想通了,答案非常明显。
就像我说的,我已经在使用 gulp-file-include
将这种类型的东西添加到我的 PHP 文件中。出于某种原因,我假设这不适用于 CSS 个文件,但它完全可以正常工作。
我是 Gulp 的新手,但我正在使用它来管理创建 WordPress 主题的构建过程。我的 package.json 设置得很好,我希望我的 style.css 能够反映 package.json。例如,如果我在 package.json 中将我的 version
设置为 0.0.2
,style.css 应该反映在 运行 我的构建任务之后。
再举个例子,如果我把这个作为我的 package.json:
{
"name": "new-site",
"description": "A basic framework for a WordPress template",
"version": "0.0.1",
"repository": "https://github.com/revxx14/new-site",
"license": "MIT"
}
这将是我的 style.css,在 运行 gulp build
之后:
/*
Theme Name: new-site
Theme URI: https://github.com/revxx14/new-site
Description: A basic framework for a WordPress template
Version: 0.0.1
License: MIT
*/
我已经安装了 json-file
软件包,因为我正在使用 gulp-file-include
包含来自 package.json 的版本号以用于缓存清除目的。
您可以在此处查看我的整个 gulpfile:https://github.com/revxx14/new-site/blob/master/gulpfile.js
想通了,答案非常明显。
就像我说的,我已经在使用 gulp-file-include
将这种类型的东西添加到我的 PHP 文件中。出于某种原因,我假设这不适用于 CSS 个文件,但它完全可以正常工作。