less - Grunt、Less 和文件监视

标签 less gruntjs

我正在努力做某事。我的项目是这样的:

/app
    /assets
        /components
        /stylesheets
            /less
                /file1.less
                /file2.less
                /file3.less
                /importAll.less
            /css

我想要它以便当 file1 , file2 , 或 file3已保存 importAll.less文件被编译成css并放入/css/style.css .这是我得到的。
less: {
    development: {
        options: {
            paths: ["./assets/stylesheets/less"],
            yuicompress: true
        },
        files: {
            "./assets/stylesheets/css/style.css": "./assets/stylesheets/less/importAll.less"
        }
    }
}

我不确定如何让文件观察器工作。

最佳答案

我得到它与以下工作!

module.exports = function(grunt) {
    grunt.initConfig({
        less: {
            development: {
                options: {
                    paths: ["./assets/stylesheets/less"],
                    yuicompress: true
                },
                files: {
                    "./assets/stylesheets/css/style.css": "./assets/stylesheets/less/style.less"
                }
            }
        },
        watch: {
            files: "./assets/stylesheets/less/*",
            tasks: ["less"]
        }
    });
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-watch');
};

关于less - Grunt、Less 和文件监视,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15664628/

相关文章:

css - 如何缩小 Less 文件输出?

google-chrome - 为 Firefox 使用 lesscss 和浏览器 hack

css - 有没有办法定义别名并在 Sass 或 Less 中使用它的 CSS 定义

node.js - 在browserify中需要cdn库而不将其捆绑在最终的js文件中

angularjs - 服务器挂起运行 "concurrent:server"(并发)任务

javascript - 如何使用 grunt 目标

npm - 为什么 Grunt 会进入 devDependencies?

gruntjs - 使用 Bower 和 Grunt 自定义语义用户界面

css - "bootstrap/less/bootstrap.less"覆盖所有选择器(与 2013 相比)

eclipse - 保存Grails项目时自动刷新浏览器?