【问题标题】:using updating my css file using grunt使用 grunt 更新我的 css 文件
【发布时间】:2016-03-02 09:31:27
【问题描述】:

我不确定我是否误解了 grunt 的用途。我期待编写 .scss 文件,然后 grunt 将我在 sass 中编写的内容更新到我的 .css 文件中。我学会了配置我的 grunfile.js here 。但是,在运行 grunt watch 之后,当我更改它时,grunt 会一直监视并执行我的 .scss 文件。然而,出乎我的意料,它并没有更新我的 .css 文件。下面是我的 gruntfile.js

module.exports = function(grunt) {
  grunt.initConfig ({
    sass: {
      dist: {
        files: {
          'public/stylesheets/style.css' : 'sass/style.scss'
        },
        options: {
          loadPath: ['bower_components/foundation-apps/scss']
        }
      }
    },
    watch: {
      source: {
        files: ['**/*.sass','**/*.scss'],
        tasks: ['sass'],
        options: {
          livereload: true, // needed to run LiveReload
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('default', ['sass']);
};

在我的页面中,我只引用了 style.css 并希望它会使用我的 .scss 内容进行更新。请问我错过了什么?任何帮助,将不胜感激。

【问题讨论】:

    标签: javascript css node.js sass grunt-contrib-watch


    【解决方案1】:

    尝试将watch 添加到default 任务中:

    grunt.registerTask('default', ['watch', 'sass']);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-19
      • 2014-10-16
      • 1970-01-01
      • 2014-07-22
      • 2014-01-21
      • 1970-01-01
      • 2015-08-08
      相关资源
      最近更新 更多