html - 更改 css 文件和 htmls 或 jade 中的 css 类名称的 Grunt 任务

标签 html css gruntjs pug

我想知道是否有任何 Grunt 任务可以将类的名称更改为唯一的名称?

例如 .container -> .uniqueName_container

或只是一些随机字母或数字,如 google: .container -> .jh72ab

但是在 html/jade 和 css 文件中都这样做吗?

最佳答案

这似乎支持使用函数输出替换值;您可以将用于生成标识符的代码放在那里。

https://github.com/yoniholmes/grunt-text-replace

例子:

replacements: [{
  from: 'Foo',
  to: function (matchedWord) {   // callback replacement
    return matchedWord + ' Bar';
  }
}]

关于html - 更改 css 文件和 htmls 或 jade 中的 css 类名称的 Grunt 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38361024/

相关文章:

javascript - 如何删除直接包含字符串的元素 - 忽略子元素

javascript - 如何使用 jquery 同步音频媒体组

html - 为什么打印的时候图片在div外面?

css - 如何使 "text-overflow: ellipsis"在 float div 上工作?

javascript - 滑动 div 在 float div 下

windows - 在 Windows 上运行 grunt.cmd 的多个问题

php - 如何使用 grunt 缩小我的 index.php?

html - 自定义文本下划线(使用 + 和 - 符号)

CSS:怎么说 .class:last-of-type [类,而不是元素!]

javascript - Gruntjs Livereload 正在观看但未更新