twitter-bootstrap-3 - Bootstrap "grunt watch"不会创建 bootstrap.min.css

标签 twitter-bootstrap-3 gruntjs watch

我几乎完全不熟悉咕噜声。
我在 bootstrap 3.1.1 和 grunt watch 中使用了 grunt -命令效果很好。我的 bootstrap.min.css 文件每次都被编译。 (我上传了我的 bootstrap.min.css)

后来我丢失了我的 3.1.1 grunt 文件(长话短说我的电脑崩溃了)。
所以现在使用 Bootstrap 3.2.0 我要重新建立我的 grunt-work-flow。

但是现在当我使用 grunt watch我只编译了“bootstrap.css”和“bootstrap.theme.css”。

我花了最后几个小时来解决这个问题,但没有成功。

我要什么
我要 grunt watch编译缩小的“bootstrap.min.css”
那么我如何在 watch 上调用 min.css 函数?

我会很高兴得到一些帮助。

最佳答案

Grunt watch 只会监视文件然后运行你设置的任务。我假设在你的 gruntfile 中你有这样的东西:

css: {
    files: [
      'bootstrap.css',
    ],
    tasks: ['less'],
  },

在较少的任务中,您应该有如下内容。请注意 cleancss选项设置为真:
options: {
      cleancss: true
    },

    files: {
      "dest/bootstrap.min.css": "src/bootstrap.css",
      "dest/bootstrap.theme.min.css": "src/bootstrap.theme.css"
    }

更新:

根据您上传的文件,您应该运行 cssmin:core当 watch 被触发时的任务。

更新 2:
要更新监视任务,您只需将 cssmin:core 任务添加到 less 子任务:
less: {
        files: 'less/**/*.less',
        tasks: ['less', 'cssmin:core]
      }

在这里,您告诉它运行 less 任务,然后是 cssmin在观看时更改较少文件之一时的任务。

关于twitter-bootstrap-3 - Bootstrap "grunt watch"不会创建 bootstrap.min.css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25189749/

相关文章:

asp.net-mvc - 向 ASP.NET MVC 4 中的单选按钮添加自定义类

Javascript 不适用于 jsfiddle

gruntjs - 如何让 grunt-watch 在不同的构建任务下实时重新加载 HTML 更改

linux - 在读取时使用 tail -f 监视文件并执行命令?

javascript - Bootstrap 崩溃正在覆盖下一个 Bootstrap 崩溃标题

html - Bootstrap 中的垂直顺序网格

javascript - Grunt - 解析非字符串(例如数组)模板

javascript - 让 Angular 和 intern.io 一起工作

xcode - 观看Xcode中的表达式

javascript - 检测 Javascript 对象的变化