Grunt手表没有运行任务

时间:2014-12-08 17:25:50

标签: javascript node.js gruntjs less

我正在尝试使用livereload和更少的运行grunt服务器。 在grunt less上,它确实编译了我的较少文件,但是当我更改一个较少的文件时,我得到的是

>> File "app\style\componenets\components.less" changed.

我也尝试过:开发但仍然没有运气。 顺便说一下,我改变了每个文件的livereload,虽然在监视任务中我只配置了较少的位置..

提前致谢!

'use strict';

// Gruntfile with the configuration of grunt-express and grunt-open. No livereload yet!
module.exports = function(grunt) {

    // Load Grunt tasks declared in the package.json file
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    console.log(__dirname + '\\app\\');

    // Configure Grunt 
    grunt.initConfig({

        // grunt-express will serve the files from the folders listed in `bases`
        // on specified `port` and `hostname`
        express: {
            all: {
                options: {
                    bases: ['app'],
                    port: 8080,
                    hostname: "0.0.0.0",
                    livereload: true
                }
            }
        },
        less: {
            development: {
                options: {
                    compress: true,
                    yuicompress: true
                },
                files: {
                    // target.css file: source.less file
                    "app/main.css": "app/style/main.less"
                }
            }
        },
        // grunt-watch will monitor the projects files
        watch: {
            less: {
                files: ['<%= express.all.options.base%>/style/*.less', '<%= express.all.options.base%>/style/componenets/*.less'],
                tasks: ['less']
            }
        },

        // grunt-open will open your browser at the project's URL
        open: {
            all: {
                // Gets the port from the connect configuration
                path: 'http://localhost:<%= express.all.options.port%>/#/'
            }
        }

    });

    // Creates the `server` task
    grunt.registerTask('server', [
        'express',
        'open',
        'watch'
    ])

    // Creates the `less` task
    grunt.registerTask('less', ['less']);
};

1 个答案:

答案 0 :(得分:0)

为什么gruntfile末尾的别名任务?

// Creates the `less` task
grunt.registerTask('less', ['less']);

您的较少任务已经通过您的配置定义!删除那一行,你可能很好......

编辑:你的less config中至少有1个拼写错误:

错误:

&lt;%= express.all.options.base%&gt; / style / *。less'

正确的:

&lt;%= express.all.options.bases%&gt; / style / *。less'