Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt 0.4 less task : How to not concatenate destination files

Tags:

gruntjs

less

I want to generate .css partial files from the corresponding .less files

I use the latest versions available from npm, [email protected], [email protected]

Prior to Grunt version 0.4 I could simply specify the pattern:

htdocs/less/*.less as source

htdocs/css/*.css as destination

and all the files from the folder htdocs/less would be generated into the folder htdocs/css

Since v0.4 the destination pattern does no longer work, all files from the folder htdocs/less are concatenated into one file named *.css

How can I configure the task that it generates all files instead concatenating them into one file.

I do not want list the files individually.

Couldn't find an answer in the Grunt documentation http://gruntjs.com/configuring-tasks#files does

Thank You.

My Gruntfile.js (extract):

module.exports = function (grunt) {
    grunt.initConfig({
        less: {
            development: {
                files: {
                    "htdocs/css/*.css": "htdocs/less/*.less"
                }
            }
        },
    });
};
like image 619
user2157720 Avatar asked Dec 09 '22 17:12

user2157720


1 Answers

You'd want to read the Building the files object dynamically section in the docs.

This would be a direct translation from your current config:

module.exports = function (grunt) {
    grunt.initConfig({
        less: {
            development: {
                files: [{
                    expand: true,        // Enable dynamic expansion.
                    cwd: 'htdocs/less',  // Src matches are relative to this path.
                    src: ['*.less'],     // Actual pattern(s) to match.
                    dest: 'htdocs/css',  // Destination path prefix.
                    ext: '.css',         // Dest filepaths will have this extension.
                }]
            }
        },
    });
};
like image 112
Sindre Sorhus Avatar answered Jun 04 '23 23:06

Sindre Sorhus