【问题标题】:Grunt is Running "watch" task and Waiting... forever. Is it my Gruntfile.js syntax?Grunt 正在运行“监视”任务并等待......永远。是我的 Gruntfile.js 语法吗?
【发布时间】:2015-09-14 05:00:03
【问题描述】:

期待 Sassier Bootstrap 4,我(试图)在 Bootstrap 3.3.5 和 setting up the required Gruntfile.js 文件上从 Less 切换到 Sass。我在编译 Less 时没有问题,但无法让 Grunt 与 Sass 一起工作,具体来说,$ grunt$ grunt watch 都可以帮助我

Running "watch" task Waiting...

永远。

不用说它不编译。我试过$ grunt watch --verbose,得到了很多绿色OKs。

我认为我的gruntfile.js 中有一些错误或效率低下,但由于这是 Baby 的第一个 Gruntfile.js,所以我被困在了这里。你能看出是什么原因造成的吗?

    /*** Created by morgan on 9/13/15. */    

    module.exports = function (grunt) {
          grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),

        sass: {
          dev: {
        options: {
          includePaths: ['static/sass']
        },
        dev: {
          options: {
            style: 'expanded',
            compass: false
          },
          files: {
            'css/styles.css': 'sass/styles.scss'
          }
        }
      }
    },

    watch: {
      grunt: { files: ['Gruntfile.js'] },
      sass: {
        files: [
          'sass/**/*.scss'
        ],
        tasks: ['sass:dev']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('default', 'watch')
};

我的项目目录,如果有帮助的话:

(Django project)
app
├── static
│   ├── sass
│   │   ├── _bootstrap.scss
│   │   └── styles.scss
│   ├── css
│   │   └── styles.css
│   └── jquery
├── node_modules
│   ├── grunt
│   ├── grunt-contrib-sass
│   └── grunt-contrib-watch
├── Gruntfile.js
└── package.json

【问题讨论】:

    标签: gruntjs grunt-contrib-watch bootstrap-sass gruntfile


    【解决方案1】:

    @maxbeattySlack#help 中提供了一个可执行的 Gruntfile.js 和 package.json。 on GitHub 这里: https://github.com/maxbeatty/example-grunt-sass-bootstrap

    请注意,如果您将此模板用于您自己的 sass-bootstrap 项目,您可能需要更改 files: 路径以匹配您自己的路径。

    Gruntfile.js

    module.exports = function (grunt) {
      grunt.initConfig({
        sass: {
          dev: {
            options: {
              outputStyle: 'expanded'
            },
            files: {
              'static/css/styles.css': 'static/sass/styles.scss'
            }
          }
        },
    
        watch: {
          sass: {
            files: [
              'static/sass/**/*.scss'
            ],
            tasks: ['sass:dev']
          }
        }
      });
    
      grunt.loadNpmTasks('grunt-sass');
      grunt.loadNpmTasks('grunt-contrib-watch');
      grunt.registerTask('default', 'watch')
    };
    

    package.json 依赖:

      "devDependencies": {
        "grunt": "^0.4.5",
        "grunt-contrib-watch": "^0.6.1",
        "grunt-sass": "^1.0.0"
      }
    

    同样,两者都来自@maxbeatty。 (目录不变)。 watch 故障排除存档在 Slack 频道中以供进一步阅读。

    【讨论】:

      猜你喜欢
      • 2014-09-30
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 1970-01-01
      • 2015-02-02
      • 2016-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多