-2

Why doesn't the GruntJS watch for the css/ folder? But it successfully watches for /js folder. Manual start function by default or any separate function using grunt-cli command grunt or grunt cssmin works correctly too...

My GruntJS code is:

module.exports = function(grunt) {

// 1. Вся настройка находится здесь
var d = new Date();
var y = d.getFullYear();
var bannerText = 'Created by Andrew Dyachenko ' + y + ''
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
        dist: {
            options: {
                banner: '/*' + bannerText + '*/\n'
            },
            files: {
                'js/main.min.js': ['js/main.js']
            }
        }
    },
    cssmin: {
      target: {
        files: [{
          expand: true,
          cwd: 'css/',
          src: ['*.css', '!*.min.css'],
          dest: 'css/',
          ext: '.min.css'
        }]
      }
    },
    watch: {
        options: {
            livereload: true
        },
        scripts: {
            files: ['js/*.js', 'css/*.css'],
            tasks: ['process']
        }
    }
});

// 3. Тут мы указываем Grunt, что хотим использовать этот плагин
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-newer');

// 4. Указываем, какие задачи выполняются, когда мы вводим «grunt» в терминале
grunt.registerTask('process', ['newer:uglify', 'cssmin']);
grunt.registerTask('default', ['uglify', 'cssmin', 'watch']);

};

Grigori Melnik
  • 4,067
  • 2
  • 34
  • 40
north.inhale
  • 483
  • 2
  • 9
  • 20
  • We probably need to see your directory structure to know for sure. – Jordan Kasper Jan 05 '15 at 13:43
  • You don't need to see all folders tree, it doesn't matter - because manual function running is working fine, folders way in this both functions is simmilar. One function is working fine, the second with the same way is working only for js folder – north.inhale Jan 06 '15 at 15:42

1 Answers1

0

I think my problemm was in undefined bug. But now after small rebuild, everythin is working fine.

module.exports = function(grunt) {

var d = new Date();
var y = d.getFullYear();
var bannerText = 'Created by Andrew Dyachenko ' + y + '';

grunt.initConfig({

    jshint: {
        files: ['js/*.js', '!js/*.min.js'],
        options: {
            // eqeqeq: false,
            // curly: true,
            // es3: true,
            // es5: true,
            // noempty: true,
            // shadow: true,
            // unused: true,
            // boss: true,
            // debug: true,
            globals: {
                jQuery: true
            }
        }
    },

    uglify: {
        dist: {
            options: {
                banner: '/*' + bannerText + '*/\n'
            },
            files: [{
              expand: true,
              cwd: 'js/',
              src: ['*.js', '!*.min.js'],
              dest: 'js/',
              ext: '.min.js'
          }]
        }
    },

    cssmin: {
      target: {
        files: [{
          expand: true,
          cwd: 'css/',
          src: ['*.css', '!*.min.css'],
          dest: 'css/',
          ext: '.min.css'
        }]
      }
    },

    watch: {
        options: {
            livereload: true
        },
        files: ['<%= jshint.files %>', ['css/*.css', '!css/*.min.css']],
        tasks: ['process']
    }
});

grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('process', ['newer:jshint', 'uglify', 'cssmin']);
grunt.registerTask('default', ['jshint', 'uglify', 'cssmin', 'watch']);

};

north.inhale
  • 483
  • 2
  • 9
  • 20