grunt手表/ sass工作不正常

这是我第一次尝试用grunt创建一个工作流程我已经设法做出几乎所有的工作,但是当我运行grunt时,sass的watch任务没有做任何事情只是输出文件已经改变,并且它没有任何错误

gruntfile.js:

'use strict';

module.exports = function(grunt) {

// All configuration goes here
grunt.initConfig({

    //jekyll tasks

    jekyll: {
    //Builds jekyll to local development
        dist: {
            options: {
                config: '_config_dev.yml',
                dest: './_local',
            }
        },
    //Builds jekyll for deploying
        live: {
            options: {
                config: '_config.yml',
                dest: './_live',
            }
        }
    },

    //jshint task

    jshint: {
        options: {
            jshintrc: '.jshintrc'
        },
        all: [
            './!Gruntfile.js',
            './assets/js/*.js',
            './assets/js/plugins/*.js',
            './!assets/js/scripts.min.js'
        ]
    },

    // Uglify
    uglify: {
        dist: {
            files: {
                './assets/js/scripts.min.js': [
                './assets/js/plugins/*.js',
                './assets/js/_*.js'
                ]
            }
        }
    },

    //imagemin task
    imagemin: {
        dist: {
            options: {
                optimizationLevel: 7,
                progressive: true
            },
        files: [{
            expand: true,
            cwd: './img/',
            src: '{,*/}*.{png,jpg,jpeg}',
            dest: './img/'
            }]
        }       
    },

    //svgmin task
    svgmin: {
        dist: {
            files: [{
                expand: true,
                cwd: './img/',
                src: '{,*/}*.svg',
                dest: './img/'
            }]
        }
    },

    //Sass tasks

    sass: {
        //Compiles sass to css for local test
        dist: {
            files: [{
                expand: true,
                cwd: 'assets/sass/',
                src: ['**/*.scss'],
                dest: 'assets/css/',
                ext: '.css'
            }]
        },
        //Compiles sass to css for live deployment
        live: {
            options: {
                style: 'compressed'
            },
            files: [{
                expand: true,
                cwd: 'assets/sass',
                src: ['**/*.scss'],
                dest: 'assets/css',
                ext: '.css'
            }]
        },
        //Compiles sass for browser sync
        style: {
            options: {
                style: 'compressed'
            },
            files: [{
                expand: true,
                cwd: 'assets/sass',
                src: ['**/*.scss'],
                dest: 'assets/css',
                ext: '.css'
            }]
        },

    },

    //Watch tasks
    watch: {

        scss: {
            files: 'assets/sass/*.scss',
            task: ['clean', 'sass:dist'],
            options: {
                spaw: false,
                },
        },
        style: {
            files: 'assets/sass/*.scss',
            task: ['sass:style'],
        },
        js: {
            files: [
                    '<%= jshint.all %>'
                    ],
            tasks: ['jshint','uglify'],
            },
        jekyll: {
            files: [
                    '_layouts/*.html', 
                    '_includes/*.html', 
                    'assets/css/main.css', 
                    '*.html', 
                    '*.md', 
                    '_post/*.md'
                    ],
            tasks: ['jekyll:dist'],
        },
        livereload: {
            options: {
                livereload: true,
            },
            files: [
                    '_local/**'
                    ],
                },
        },  

    //Clean task
    clean: {
        dist: [
            'assets/css/main.css',
            'assets/js/scripts.min.js'
        ]   
    },

    //Server
    connect: {
        server : {
            options: {
                livereload: true,
                base : './_local/',
                port: 4000
        }
    }
}



});

// Load the plugins

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-svgmin');  
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-clean');


// Custom tasks
grunt.registerTask('dev', ['clean', 'sass:dist', 'uglify', 'imagemin','svgmin', 'jekyll:dist', 'connect:server', 'watch']);
grunt.registerTask('default', ['clean', 'sass:live', 'uglify','imagemin', 'svgmin', 'jekyll:live']);
grunt.registerTask('css', ['clean', 'sass:dist', 'uglify', 'imagemin','svgmin', 'jekyll:dist', 'connect:server', 'watch:style']);

};

我的文件结构是下一个:

gruntfile.js
assets/
      css/
      sass/

这是运行grunt dev任务时终端的输出,因为您看不到任何更改

┌[~/git/Nutricorp] [dev *]← →[*+?] 
└[ % ± ]>> grunt dev -v                                                                                                                                                         O_O 
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Initializing config...OK

Registering "grunt-contrib-watch" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-watch/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch

Registering "grunt-contrib-imagemin" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-imagemin/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-imagemin/package.json...OK
Loading "imagemin.js" tasks...OK
+ imagemin

Registering "grunt-contrib-connect" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-connect/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-connect/package.json...OK
Loading "connect.js" tasks...OK
+ connect

Registering "grunt-svgmin" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-svgmin/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-svgmin/package.json...OK
Loading "svgmin.js" tasks...OK
+ svgmin

Registering "grunt-contrib-jshint" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-jshint/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-jshint/package.json...OK
Loading "jshint.js" tasks...OK
+ jshint

Registering "grunt-contrib-uglify" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-uglify/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-uglify/package.json...OK
Loading "uglify.js" tasks...OK
+ uglify

Registering "grunt-jekyll" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-jekyll/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-jekyll/package.json...OK
Loading "jekyll.js" tasks...OK
+ jekyll

Registering "grunt-contrib-sass" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-sass/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-sass/package.json...OK
Loading "sass.js" tasks...OK
+ sass

Registering "grunt-contrib-clean" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-clean/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-clean/package.json...OK
Loading "clean.js" tasks...OK
+ clean
Loading "Gruntfile.js" tasks...OK
+ css, default, dev

Running tasks: dev

Running "dev" task

Running "clean" task

Running "clean:dist" (clean) task
Verifying property clean.dist exists in config...OK
Files: assets/css/main.css -> dist
Options: force=false, no-write=false
Options: force=false, no-write=false
Cleaning assets/css/main.css...OK

Running "sass:dist" (sass) task
Verifying property sass.dist exists in config...OK
Files: assets/sass/_config.scss -> assets/css/_config.css
Files: assets/sass/_grids.scss -> assets/css/_grids.css
Files: assets/sass/_main-page.scss -> assets/css/_main-page.css
Files: assets/sass/_menu.scss -> assets/css/_menu.css
Files: assets/sass/main.scss -> assets/css/main.css
Options: (none)
Writing assets/css/main.css...OK
File assets/css/main.css created.

Running "uglify" task

Running "uglify:dist" (uglify) task
Verifying property uglify.dist exists in config...OK
Files: [no src] -> ./assets/js/scripts.min.js
Options: banner="", footer="", compress={"warnings":false}, mangle={}, beautify=false, report="min"
>> Destination ./assets/js/scripts.min.js not written because src files were empty.

Running "imagemin" task

Running "imagemin:dist" (imagemin) task
Verifying property imagemin.dist exists in config...OK
Options: cache, optimizationLevel=7, progressive
Minified 0 images (saved 0 B)

Running "svgmin" task

Running "svgmin:dist" (svgmin) task
Verifying property svgmin.dist exists in config...OK
Options: (none)
Total saved: 0 B

Running "jekyll:dist" (jekyll) task
Verifying property jekyll.dist exists in config...OK
File: [no files]
Options: config="_config_dev.yml", dest="./_local"
`jekyll build --destination ./_local --config _config_dev.yml` was initiated.


Jekyll output:
Configuration file: _config_dev.yml
            Source: /home/cruznick/git/Nutricorp
       Destination: ./_local
      Generating... done.

Running "connect:server" (connect) task
Verifying property connect.server exists in config...OK
File: [no files]
Options: protocol="http", port=4000, hostname="0.0.0.0", base="./_local/", directory=null, keepalive=false, debug=false, livereload, open=false, useAvailablePort=false, middleware=null
Started connect web server on http://0.0.0.0:4000

Running "watch" task
Waiting...Verifying property watch exists in config...OK
Verifying property watch.scss.files exists in config...OK
Verifying property watch.style.files exists in config...OK
Verifying property watch.js.files exists in config...OK
Verifying property watch.jekyll.files exists in config...OK
Live reload server started on port: 35729
Watching assets/sass/_config.scss for changes.
Watching assets/sass/_grids.scss for changes.
Watching assets/sass/_main-page.scss for changes.
Watching assets/sass/_menu.scss for changes.
Watching assets/sass/main.scss for changes.
Watching assets/sass/_config.scss for changes.
Watching assets/sass/_grids.scss for changes.
Watching assets/sass/_main-page.scss for changes.
Watching assets/sass/_menu.scss for changes.
Watching assets/sass/main.scss for changes.
Watching _layouts/main.html for changes.
Watching _includes/head.html for changes.
Watching _includes/menu.html for changes.
Watching assets/css/main.css for changes.
Watching index.html for changes.
Watching .git for changes.
Watching .sass-cache for changes.
Watching _includes for changes.
Watching _layouts for changes.
Watching _live for changes.
Watching _local for changes.
Watching _locales for changes.
Watching _plugins for changes.
Watching _posts for changes.
Watching assets for changes.
Watching img for changes.
Watching node_modules for changes.
Watching README.md for changes.
OK
>> File "assets/sass/_menu.scss" changed.

Live reloading assets/sass/_menu.scss...
Live reloading assets/sass/_menu.scss...
Completed in 0.002s at Thu Mar 27 2014 08:02:04 GMT-0600 (CST) - Waiting...

我不知道为什么它不工作没有任何错误消息任何想法在此先感谢ps:也尝试与咕噜contrib指南针,它没有工作我正在运行archlinux与红宝石2.1.0p0和sass和指南针宝石安装一切工作很好ps2:如果这很重要,我的shell是zsh


在你的手表配置你有task:而不是tasks:

指定该属性的关键是复数。

链接地址: http://www.djcxy.com/p/78967.html

上一篇: grunt watch/sass not working correctly

下一篇: Grunt with Compass and Watch compiles slow