grunt sass为输出文件添加注释

ttm*_*tmt 1 wordpress sass gruntjs

我正在使用grunt sass在Wordpress主题中输出我的CSS.

我通常会将我的CSS输出到thestyles.css并在style.css中使用@import(thestyles.css)

我正在使用respond.js所以我不能在style.css文件中使用@import.

我想直接输出我的CSS到style.css但我需要顶部的注释为Wordpress.

*/
Theme Name: Forum
Theme URI: 
Description: 
Author:
Author URI: 
Version: 1.0
Tags:
/*
Run Code Online (Sandbox Code Playgroud)

我可以使用横幅添加评论吗?

sass: {
  dist: {
    options: {
      banner:
      '
      */
      Theme Name: Forum
      Theme URI: 
      Description: 
      Author:
      Author URI: 
      Version: 1.0
      Tags:
      /*
      '
    },
    files: {
      "src/php/wp-content/themes/forum/style.css": "src/sass/forum/output.scss"
    }
  }
},
Run Code Online (Sandbox Code Playgroud)

fer*_*sik 5

你应该放一个!因此,缩小器不会删除横幅.

您可以从package.json中提取信息,如下所示:

在Gruntfile.js中

pkg: pkg: grunt.file.readJSON('package.json'),
sass: {
  dist: {
    options: {
      banner: '/*!\n' +
              ' * Theme Name: Forum\n' +
              ' * Theme URI: <%= pkg.url %>\n' +
              ' * Description: <%= pkg.description %>\n' +
              ' * Author: <%= pkg.author.name %>\n' +
              ' * Author URI: <%= pkg.author.email %>\n' +
              ' * Version: <%= pkg.version %>\n' +
              ' * Tags:\n' +
              ' */\n'
Run Code Online (Sandbox Code Playgroud)