2013-05-30 3 views
4

Ниже мой файл Grunt. Моя команда watch:news не работает, и я не уверен, почему.Не удается запустить задачу «Следить» Grunt?

Когда я запускаю в подробном режиме, я вижу, что все модули NPM загружаются без проблем, и он проверяет, что задача watch:news работает так, как должна быть, но тогда она просто не понимает, что любые изменения имеют произошло?

Я уверен, что это, вероятно, опечатка или небольшая проблема с легкостью, я просто не могу это понять.

Любая помощь очень ценится!

module.exports = function (grunt) { 

    /* 
     Grunt installation: 
     ------------------- 
      npm install -g grunt-cli 
      npm install -g grunt-init 
      npm init (creates a `package.json` file) 

     Project Dependencies: 
     --------------------- 
      npm install grunt --save-dev 
      npm install grunt-contrib-watch --save-dev 
      npm install grunt-contrib-jshint --save-dev 
      npm install grunt-contrib-uglify --save-dev 
      npm install grunt-contrib-requirejs --save-dev 
      npm install grunt-contrib-sass --save-dev 
      npm install grunt-contrib-imagemin --save-dev 

     Example Usage: 
     -------------- 
      grunt -v 
      grunt release -v 
    */ 

    // Project configuration. 
    grunt.initConfig({ 

     // Store your Package file so you can reference its specific data whenever necessary 
     pkg: grunt.file.readJSON('package.json'), 

     dir: { 
      static: './tabloid/webapp/static/', 
      static_js: '<%= dir.static %>' + 'js/', 
      static_sass: '<%= dir.static %>' + 'sass/', 
      static_css: '<%= dir.static %>' + 'stylesheets/', 
      static_img: '<%= dir.static %>' + 'img/' 
     }, 

     jshint: { 
      files: ['<%= dir.static %>**/*.js', 
        '!<%= dir.static_js %>jasmine/lib/**/*.js', 
        '!<%= dir.static_js %>build.js', 
        '!<%= dir.static_js %>compiled/**/*.js', 
        '!<%= dir.static_js %>locator/**/*.js', 
        '!<%= dir.static_js %>msie/**/*.js', 
        '!<%= dir.static_js %>vendor/**/*.js'], 
      options: { 
       curly:  true, 
       eqeqeq:  true, 
       immed:  true, 
       latedef: true, 
       noarg:  true, 
       sub:  true, 
       undef:  true, 
       boss:  true, 
       eqnull:  true, 
       browser: true, 
       multistr: true, 
       newcap:  false, 

       globals: { 
        // AMD 
        module:  true, 
        require:  true, 
        requirejs: true, 
        define:  true, 

        // Environments 
        console:  true, 

        // General Purpose Libraries 
        $:   true, 
        jQuery:  true, 
        EventEmitter: true, 

        // Testing 
        sinon:  true, 
        describe:  true, 
        it:   true, 
        expect:  true, 
        beforeEach: true, 
        afterEach: true 
       } 
      } 
     }, 

     requirejs: { 
      compile: { 
       options: { 
        baseUrl: '<%= dir.static_js %>', 
        paths: { 
         'jquery-1': 'vendor/jquery-1/jquery.min', 
         'jquery': 'vendor/jquery-2/jquery.min', 
         'domReady': 'vendor/require/domReady', 
         'translation': 'module/translations/news' 
        }, 
        exclude: ['config', 'jquery' ], 
        name: 'define', 
        out: '<%= dir.static_js %>compiled/all.js', 
        fileExclusionRegExp: /^\.|node_modules|Gruntfile|\.md|package.json/ 
       } 
      } 
     }, 

     sass: { 
      dist: { 
       options: { 
        style: 'compressed', 
        require: ['<%= dir.static_sass %>helpers/url64.rb'] 
       }, 
       expand: true, 
       cwd: '<%= dir.static_sass %>', 
       src: ['*.scss', '!_*.scss'], 
       dest: '<%= dir.static_css %>', 
       ext: '.css' 
      }, 
      dev: { 
       options: { 
        style: 'expanded', 
        debugInfo: true, 
        lineNumbers: true, 
        require: ['<%= dir.static_sass %>helpers/url64.rb'] 
       }, 
       expand: true, 
       cwd: '<%= dir.static_sass %>', 
       src: ['*.scss', '!_*.scss'], 
       dest: '<%= dir.static_css %>', 
       ext: '.css' 
      }, 
      news: { 
       options: { 
        style: 'expanded', 
        debugInfo: true, 
        lineNumbers: true, 
        require: ['<%= dir.static_sass %>helpers/url64.rb'] 
       }, 
       expand: true, 
       cwd: '<%= dir.static_sass %>/services/news/', 
       src: ['*.scss'], 
       dest: '<%= dir.static_css %>/services/news/', 
       ext: '.css' 
      } 
     }, 

     // `optimizationLevel` is only applied to PNG files (not JPG) 
     imagemin: { 
      png: { 
       options: { 
        optimizationLevel: 7 
       }, 
       files: [ 
        { 
         expand: true, 
         cwd: '<%= dir.static %>img/', 
         src: ['**/*.png'], 
         dest: '<%= dir.static %>img/', 
         ext: '.png' 
        } 
       ] 
      }, 
      jpg: { 
       options: { 
        progressive: true 
       }, 
       files: [ 
        { 
         expand: true, 
         cwd: '<%= dir.static %>img/', 
         src: ['**/*.jpg'], 
         dest: '<%= dir.static %>img/', 
         ext: '.jpg' 
        } 
       ] 
      } 
     }, 

     // Run: `grunt watch -v` from command line for this section to take effect 
     // The -v flag is for 'verbose' mode, this means you can see the Sass files being compiled along with other important information 
     watch: { 
      all: { 
       files: ['<%= jshint.files %>', '<%= sass.dev.src %>'], 
       tasks: ['default'] 
      }, 
      news: { 
       files: ['<%= sass.news.src %>'], 
       tasks: ['news'] 
      } 
     } 

    }); 

    // Load NPM Tasks 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.loadNpmTasks('grunt-contrib-jshint'); 
    grunt.loadNpmTasks('grunt-contrib-uglify'); 
    grunt.loadNpmTasks('grunt-contrib-requirejs'); 
    grunt.loadNpmTasks('grunt-contrib-sass'); 
    grunt.loadNpmTasks('grunt-contrib-imagemin'); 

    // Default Task 
    grunt.registerTask('default', ['jshint', 'sass:dev']); 

    // News Task 
    grunt.registerTask('news', ['sass:news']); 

    // Release Task 
    grunt.registerTask('release', ['jshint', 'requirejs', 'sass:dist', 'imagemin']); 

}; 
+0

Единственное, что я могу видеть, что в 'дерзости: news' ваш' 'cwd' и опции dest' имеют ненужный косую черту в их: '<% = dir.static_sass%> */* services/news /'. Я не думаю, что это вызовет проблему, но это не помешает избавиться от них, стоит попробовать, я думаю. –

+1

Это может вам помочь - http://stackoverflow.com/questions/15577905/grunt-watch-task-block-the-command-line –

+0

В каких версиях вы используете gunt-contrib-watch и grunt-contrib-sass? – imjared

ответ

2

Разобрался проблема была сделать с просмотром <%= sass.news.src %>, который не работает, как мы используем расширенный каталог глобирование рубаки.

Решение было напрямую ссылаться на папку, я хотел смотреть: <%= dir.static_sass %>**/*.scss'

Смежные вопросы