Code Monkey home page Code Monkey logo

grunt-contrib-less's Introduction

grunt-contrib-less v3.0.0 Build Status

Compile LESS files to CSS

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-contrib-less --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-contrib-less');

This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that you upgrade, but in case you can't please use v0.3.2.

Less task

Run this task with the grunt less command.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

paths

Type: String Array Function
Default: Directory of input file.

Specifies directories to scan for @import directives when parsing. Default value is the directory of the source, which is probably what you want.

If you specify a function the source filepath will be the first argument. You can return either a string or an array of paths to be used.

rootpath

Type: String
Default: ""

A path to add on to the start of every URL resource.

compress

Type: Boolean
Default: false

Compress output by removing some whitespaces.

plugins

Type: Array
Default: null

Allows passing plugins.

optimization

Type: Integer
Default: null

Set the parser's optimization level. The lower the number, the less nodes it will create in the tree. This could matter for debugging, or if you want to access the individual nodes in the tree.

strictImports

Type: Boolean
Default: false

Force evaluation of imports.

strictMath

Type: Boolean
Default: false

When enabled, math is required to be in parenthesis.

strictUnits

Type: Boolean
Default: false

When enabled, less will validate the units used (e.g. 4px/2px = 2, not 2px and 4em/2px throws an error).

syncImport

Type: Boolean
Default: false

Read @import'ed files synchronously from disk.

dumpLineNumbers

Type: String
Default: false

Configures -sass-debug-info support.

Accepts following values: comments, mediaquery, all.

relativeUrls

Type: Boolean
Default: false

Rewrite URLs to be relative. false: do not modify URLs.

customFunctions

Type: Object
Default: none

Define custom functions to be available within your LESS stylesheets. The function's name must be lowercase. In the definition, the first argument is the less object, and subsequent arguments are from the less function call. Values passed to the function are types defined within less, the return value may be either one of them or primitive. See the LESS documentation for more information on the available types.

sourceMap

Type: Boolean
Default: false

Enable source maps.

sourceMapFilename

Type: String
Default: none

Write the source map to a separate file with the given filename.

sourceMapURL

Type: String
Default: none

Override the default URL that points to the source map from the compiled CSS file.

sourceMapBasepath

Type: String
Default: none

Sets the base path for the less file paths in the source map.

sourceMapRootpath

Type: String
Default: none

Adds this path onto the less file paths in the source map.

sourceMapFileInline

Type: Boolean
Default: false

Puts the map (and any less files) as a base64 data uri into the output css file.

outputSourceFiles

Type: Boolean
Default: false

Puts the less files into the map instead of referencing them.

modifyVars

Type: Object
Default: none

Overrides global variables. Equivalent to --modify-vars='VAR=VALUE' option in less.

banner

Type: String
Default: none

process

Type: Function(content, destinationPath) Default: none Attributes: content, destinationPath

Allows to parse the CSS content to be written to destinationPath to flow through a self defined function.

Usage Examples

less: {
  development: {
    options: {
      paths: ['assets/css']
    },
    files: {
      'path/to/result.css': 'path/to/source.less'
    }
  },
  production: {
    options: {
      paths: ['assets/css'],
      plugins: [
        new (require('less-plugin-autoprefix'))({browsers: ["last 2 versions"]}),
        new (require('less-plugin-clean-css'))(cleanCssOptions)
      ],
      modifyVars: {
        imgPath: '"http://mycdn.com/path/to/images"',
        bgColor: 'red'
      }
    },
    files: {
      'path/to/result.css': 'path/to/source.less'
    }
  }
}

Release History

  • 2021-02-21   v3.0.0   Updated to Less 4. ieCompat option removed.
  • 2021-02-20   v2.1.0   Dependency updates. New process option to modify the written CSS.
  • 2018-05-25   v2.0.0   Update less to ^3.0.0
  • 2017-03-08   v1.4.1   Fix sourceMappingURL to be the same as the CSS if not specified, #322. Rethrow the compilation error after printing the message, #315.
  • 2016-07-21   v1.4.0   Update async and less to ~2.7.1.
  • 2016-04-07   v1.3.0   Update lodash and async dependecies.
  • 2016-02-01   v1.2.0   Update to less ~2.6.0. Removed peerDependency from package.json.
  • 2015-11-09   v1.1.0   Update to less ~2.5.0.
  • 2014-12-23   v1.0.0   Update to less 2.1.0.
  • 2014-10-23   v0.12.0   Added cleancssOptions as an option. When possible, includes filename for failed writes. Ensure banner only outputs on the first file in a series.
  • 2014-07-29   v0.11.4   Fix banner and urlArgs LESS options. Fixes npm 2 peerDependencies issues.
  • 2014-06-20   v0.11.3   Update to Less ~1.7.2.
  • 2014-06-01   v0.11.2   Lock to less 1.7.0.
  • 2014-05-26   v0.11.1   Fix modifyVars to work when less file ends with a comment.
  • 2014-03-19   v0.11.0   Custom functions can return types defined by less. paths option now accepts a function. Replaced deprecated grunt.util methods. Removes deprecated grunt.lib.contrib.
  • 2014-03-01   v0.10.0   sourceMapBasepath accepts a function. Update copyright to 2014. Update .gitattributes. Update less.js to v1.7.0. Prevent CRLF in the repo. Adds modify-vars option. Changed to async stack call. Fixes data-uri test. Normalize line endings on tests.
  • 2014-01-07   v0.9.0   Bump to less 1.6.
  • 2013-12-06   v0.8.3   Support sourceMapURL.
  • 2013-11-14   v0.8.2   Support outputSourceFiles.
  • 2013-10-24   v0.8.1   Support sourceMapFilename, sourceMapBasepath and sourceMapRootpath.
  • 2013-10-22   v0.8.0   Upgrade to LESS 1.5. Support strictUnits option. Support sourceMap option. Add customFunctions option for defining custom functions within LESS. Output the source file name on error. yuicompress option now cleancss (Less changed underlying dependency)
  • 2013-08-08   v0.7.0   Downgrade no source files warning to only in verbose mode.
  • 2013-08-08   v0.6.5   Support strictMath option. Support rootpath parse option.
  • 2013-07-09   v0.6.4   Support relativeUrls option.
  • 2013-07-06   v0.6.3   Add report option for minification and gzip results.
  • 2013-07-03   v0.6.2   support syncImport.
  • 2013-06-12   v0.6.1   Support ieCompat.
  • 2013-06-09   v0.6.0   Bump less to 1.4.0.
  • 2013-05-23   v0.5.2   Improve error handling.
  • 2013-04-25   v0.5.1   Gracefully handle configuration without sources.
  • 2013-02-15   v0.5.0   First official release for Grunt 0.4.0.
  • 2013-01-23   v0.5.0rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions. Remove experimental wildcard destination support. Switching to this.files API.
  • 2012-10-18   v0.3.2   Add support for dumpLineNumbers.
  • 2012-10-12   v0.3.1   Rename grunt-contrib-lib dep to grunt-lib-contrib.
  • 2012-09-24   v0.3.0   Global options depreciated. Revert normalize linefeeds.
  • 2012-09-16   v0.2.2   Support all less options. Normalize linefeeds. Default path to dirname of src file.
  • 2012-09-10   v0.2.0   Refactored from grunt-contrib into individual repo.

Task submitted by Tyler Kellen

This file was generated on Sun Feb 21 2021 11:29:25.

grunt-contrib-less's People

Contributors

adjohnson916 avatar ananthakumaran avatar bassjobsen avatar blueimp avatar buberdds avatar cowboy avatar ctalkington avatar dependabot[bot] avatar dg avatar fatfisz avatar iki avatar jamesplease avatar jasonkarns avatar leigeber avatar lukeapage avatar montmanu avatar pdehaan avatar petrp avatar plesiecki avatar radkodinev avatar ralphsmith80 avatar rmoorman avatar sfarthin avatar sford avatar shama avatar sindresorhus avatar stevenvachon avatar viliamkopecky avatar vladikoff avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-contrib-less's Issues

Less compressor should be updated

Less has some updated syntax. However this current plugin doesn't recognise some of them.

Such as:

@import (less) "../bower_components/angular-ui/build/angular-ui.css";

Which assumes the CSS file as less allowing it to be properly imported.

Verbose option?

Could we have a 'verbose' less option available? It would help with debugging.

Add line-break option for YUI Compressor

YUI Compressor is superior to other minifiers in several ways, but the default behaviour is to output one long line, which can cause problems in some browsers.

YUI Compressor has a line-break option (as a linebreakpos argument in the cssmin function in cssmin.js).

Would it be possible to add this as an option in the less task grunt config?

Enable grunt template tags in options.paths

Users may want to use grunt templates inside of the options.paths option for LESS.

dirs: {
  source: 'source/',
  build: 'build/'
},

less: {
  compile: {
    options: {
      paths: ['<%= dirs.source %>less/include']
    },
    files: {
      '<%= dirs.build %>css/style.css': ['<%= dirs.source %>less/style.less']
    }
  }
}

Add the option to move all the assets used inside the less files to folder ./assets/ relative to the output generated css

Right now I have a task that I implemented borrowing code from the old grunt-less task. I called it cLess and it is part of what I happen to call grunt-r3m (yes, I'm not good with names). https://github.com/royriojas/grunt-r3m

The task does the same as the original but also moves the assets referenced by the less files or css files to a folder relative to the output file called /assets/ names for the assets are generated automatically. I need this feature to avoid copying the assets to the output folder, as I only have one distribution folder.

If you implement support for this I can easily drop support for this task to avoid fragmentation.

I will be more than willing to help you with this feature if you happen to find it useful.

Update for compatibility with grunt 0.4.0rc5

I need someone to help update this plugin to work with grunt 0.4.0rc5.

I had to revert the whole file src-dest mappings implicit iteration abstraction per gruntjs/grunt#606, and once again, multi tasks have to iterate over this.files manually. In addition, there's a new this.filesSrc array that contains a reduced, uniqued set of all matched src files in case the task is read-only and only cares about source files.

See:

Notes:

  • A user may specify a new option nonull in addition to src to tell grunt to keep patterns or filepaths that don't actually match files. Because of this, the task shouldn't explode if a nonexistent src filepath is encountered. I handle this in the grunt-contrib-concat by warning if not grunt.file.exists but not failing the task.

Guidelines for updating / publishing this plugin:

  • Change this project's version number to one ending in "rc5" so that it's clearer that it works with grunt 0.4.0rc5. If the existing version number doesn't end in an "a" or "rc" increment the patch version. Eg, jshint went from 0.1.0 -> 0.1.1rc5
  • Ensure grunt 0.4.0rc5-compatible plugins are specified in package.json devDependencies like this (grunt-contrib-internal can be "*")
  • Update the CHANGELOG like this
  • Regenerate the README.md file via grunt.
  • Delete node_modules, run npm cache clean and re-run npm install to test.
  • Publish to npm using --tag=master (not latest)

[no src] -> main.css

Hello,
I get the following when launching grunt. I do not understand the [no src] part as the definition of the task seems to be ok.
Any idea please ?

Running "less:main" (less) task
[D] Task source: /var/www/mobile_boilerplate/trunk/grunt/node_modules/grunt-contrib-less/tasks/less.js
Verifying property less.main exists in config...OK
Files: [no src] -> main.css
Options: paths=["/var/www/mobile_boilerplate/www/css/less/"]
Destination not written because compiled files were empty.

versions :
grunt-cli v0.1.6
grunt v0.4.0
[email protected] node_modules/grunt-contrib-less
├── [email protected]
└── [email protected] ([email protected])

extract from config.json

  "js": "/var/www/mobile_boilerplate/www/js/",
  "less": "/var/www/mobile_boilerplate/www/css/less/",
  "css": "/var/www/mobile_boilerplate/www/css/"

extract from GruntFile.js

    less: { // compile less files into css and put it in cfg.build folder
        main: {
            options: {
                paths: ["<%= cfg.less %>"]
            },
            files: {
                "<%= cfg.css %>main.css": "<%= cfg.less %>main.less"
            }
        }
    }

I also tested the following formats for files definition in vain :

'<%= cfg.css %>main.css': '<%= cfg.less %>main.less'

src:  "<%= cfg.less %>main.less",
dest: "<%= cfg.css %>main.css"

files: [
    {src: "<%= cfg.less %>main.less", dest: "<%= cfg.css %>main.css"}
]

NAN parse issue

Parse:
font-size: 0/0 a;

Output:
font:NaN a;

This shortcut is used in bootstrap, mixin.less.

Source map mediaquery is not correct

Hi!

Have you checked sass/less supporting mediaquery in compiled css files?

When I set dumpLineNumbers option to 'mediaquery' (without compressing of course), the mediaquery info doesn't show the correct line number of the less definition in the compiled css file but shows the line number that points to the compiled css which is useless while developing with less.

If I compile with lessc command from terminal, everything works fine!

Could you solve this problem because source map would be very useful.

cssmin.js makes error while minifying less file with @media query

Hey,
just experienced problem while minifying less file using this plugin with yuicompress option on:
following code
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
/* Style adjustments for high resolution devices */
}

gets compressed into this
@media print,(-o-min-device-pixel-ratio:5/

Add the option to move all the assets used inside the less files to folder ./assets/ relative to the output generated css

Right now I have a task that I implemented borrowing code from the old grunt-less task. I called it cLess and it is part of what I happen to call grunt-r3m (yes, I'm not good with names). https://github.com/royriojas/grunt-r3m

The task does the same as the original but also moves the assets referenced by the less files or css files to a folder relative to the output file called /assets/ names for the assets are generated automatically. I need this feature to avoid copying the assets to the output folder, as I only have one distribution folder.

If you implement support for this I can easily drop support for this task to avoid fragmentation.

I will be more than willing to help you with this feature if you happen to find it useful.

make it work with yeoman 1.+

Hi everyone, i am new to grunt and i can not find any guides to make it less work with yeoman 1.+. - so this is my working gruntfile-change:

I deleted all compass-related stuff and then added this to the watch:
less: {
files: ['<%= yeoman.app %>/styles/less/*.less'],
tasks: ['less']
},

the new task:
less: {
dev: {
files: {
".tmp/styles/main.css": "<%= yeoman.app %>/styles/less/*.less"
}
}
},

finally, i added less:dev to my server-task
grunt.registerTask('server', [
'clean:server',
'less:dev',
'livereload-start',
'connect:livereload',
'open',
'watch'
]);

you do not need to load the npmTask, as long as you installed grunt-contrib-less with --save-dev. This command at the top will do the work:
require('matchdep').filterDev('grunt-*').concat(['gruntacular']).forEach(grunt.loadNpmTasks);

Add 'banner' support

Just like for the concat and uglify task, I would be nice to be able to inject a banner in the compiled css.

Would this be something you would consider to add ?

Building the files object dynamically

Now Grunt have a declarative API that add files dynamically: http://github.com/gruntjs/grunt/wiki/Configuring-tasks

dynamic_mappings: {
  // Grunt will search for "**/?.js" under "lib/" when the "minify" task
  // runs and build the appropriate src-dest file mappings then, so you
  // don't need to update the Gruntfile when files are added or removed.
  files: [
    {
      expand: true,     // Enable dynamic expansion.
      cwd: 'lib/',      // Src matches are relative to this path.
      src: ['**/?.js'], // Actual pattern(s) to match.
      dest: 'build/',   // Destination path prefix.
      ext: '.min.js',   // Dest filepaths will have this extension.
    },
  ],
},

I tried the last two days to solve this problem, but without success. I can call parser.parse (data, callback) but the callback is never executed = \ \

P.S.: I don't use dynamic mapping with grunt-contrib-less because this one is not need for less, as i can @import inside main less file.

But after grunt update to 0.4.0rc7 to compile my coffee source the grunt-contrib-less broke.

Simmilar Classes with imports ignored

I have multiple classes, which only import another less file.
The problem is, that every class like that, except for the first occurence is ignored.

Example:

i have the files theme-green.less, theme-yellow.less, theme-orange.less and theme-blue.less.

in style.css i have these lines:

.theme-green{@import "theme-green.less";}
.theme-yellow{@import "theme-yellow.less";}
.theme-orange{@import "theme-orange.less";}
.theme-blue{@import "theme-blue.less";}

in the theme-* files i set a few variables and then import "theme.less":

@body-background: #FFFFFF;
@sidebar-background: #ECECEC;

@import "theme.less";

The result in the css file is only the theme for .theme-green

Please add strictMath to the render options.

To enable the strictMath option introduced in LESS.js 1.4, I updated the lessOptions as follows:

var lessOptions = {
    parse: ['paths', 'optimization', 'filename', 'strictImports', 'syncImport', 'dumpLineNumbers', 'relativeUrls'],
    render: ['compress', 'yuicompress', 'ieCompat', 'strictMath']
};

Parse error compiling Bootstrap sources.

Wiht Win Less i have no problem in the compilation, but when trying to run the Grunt task i get this error:

ParseError: Unrecognised input in src/less/commons.less on line 630, column 7:
629 .spanX (@Index) when (@Index > 0) {
630 (~".span@{index}") { .span(@Index); }
631 .spanX(@Index - 1);

In the first moment i suppouse that could be a problem with "@import" sentence, or maybe with variables, but i have concatenated all files and continue getting the same error but in a different line.

It's the project of a friend, check it out the Less sources:
https://bitbucket.org/alfonsomartinde/base-grunt/src/aa1594b99d348b20900c0c1c00ec3dc8df75ff57/src/less/commons.less?at=master

Thanks for all.

Use a variable for the output location

I am setting the output filename and location as a variable, but it is interpreting the variable as a string (a file with the variable name is being created). Below is an example

var outputFile = 'css/generated/test.css';

less: {
    dist: {
        files: {
            outputFile: ['file1.css', 'file2.css']
        }
    }
}

Is data-uri function works?

I try use data-uri function to convert image to base64 like this:

Example:
div{
background: data-uri('../data/image.jpg');
}

Output:
div{
background: url('data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==');
}

But it doesn't work :/

Which reason it can be?

Plugin does not show errors as expected

Today i found that some .less files were not builded, because there was syntax error:

.class {
 background: rgba (0,0,0,.5); /* space after rgba is syntax error */
}

Could you please make this plugin show errors? i've more fifty .less files for different components.. such plugin behaviour causes to spend lots of time...

Thanks in advance!

shorter way to specify configuration

In the usage example, the less property value is an object with the properties development and production. Is it required to put the options and files properties inside something like development and production? In my case I only have one way I want to handle .less files and was wanting to put the options and files properties directly inside the object for the less property. It would be nice if this was supported:

    less: {
      files: [{
        expand: true,
        cwd: 'styles',
        src: ['*.less'],
        dest: 'build/styles',
        ext: '.css'
      }]
    }

Support for task targets looks to be missing

When I call "grunt less" with the following code im getting "Warning: Object true has no method 'indexOf' Use --force to continue."

if I remove the targets and put the options and files directly under less it works fine

    less: {
                    t1: {
                            options: {
                                    path: ['<%= less_src_path %>'],
                            },
                            files: {
                                    //'<%= less_build_path %>/app.css':'<%= concat.less.dest %>',
                                    //Dynamic expansion 1:1
                                    expand: true,
                                    cwd:    '<%= less_src_path %>',
                                    dest:   '<%= less_build_path %>',
                                    src:    '*.less',
                                    ext:    '.less.css'
                            }
                    },
                    t2: {
                            options: {
                                    path: ['<%= less_src_path %>'],
                                    //compress: true
                                    yuicompress: true
                            },
                            files: {
                                    //'<%= less_build_path %>/app.css':'<%= concat.less.dest %>',
                                    //Dynamic expansion 1:1
                                    expand: true,
                                    cwd:    '<%= less_src_path %>',
                                    dest:   '<%= less_build_path %>',
                                    src:    '*.less',
                                    ext:    '.less.min.css'
                            }
                    }

            }

Just doesn't seem to work, at all?

Please excuse my ignorance, but this doesn't seem to work at all with my project. I have Node installed, I have Grunt install globally, I have grunt-contrib-less installed locally to my project, I'm on a Mac (if that matters). With my less files, I have one central less file for the app as a whole, and then smaller less files that go with specific parts of the web app UI in other folders. My Grunt file looks like this:


module.exports = function(grunt) {

  grunt.initConfig({
    watch: {
      files: '<config:less.files>',
      tasks: 'less'
    },
    less: {
      files: {
        'app/styles/app.css': 'app/styles/app.less'
      },
      options: {
        paths: ['app/styles', 'app/pages', 'app/widgets'],
        compress: true
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-less');

  grunt.registerTask('default', 'less');
};

But if I want to simply run grunt, I get this in the terminal:

Running "less:files" (less) task

Running "less:options" (less) task

Done, without errors.

But nothing actually happens.

paths option does not work with an array

I have got the following configuration:

    less: {
      all: {
        options: {
          paths: ["a/views/less", "b/views/less"]
        },
        files: {
          "public/css/a/application.css": "a/views/less/application.less",
          "public/css/b/application.css": "b/views/less/application.less"
        }
      }
    },

the problem is that the paths option does not take care of the second path

  "b/views/less"

According to the README.md, an Array should be allowed.

Warning: Cannot call method 'indexOf' of undefined Use --force to continue.

I'm trying to set this up to compile my LESS files into 2 css files. I have a file called "main.less" which is just a bunch of @imports to my actual less files. I put a comment in with a specific pattern to match which I use to split the file contents into 2 segments and then put each segment into 2 temporary files. The separate files get created properly as "temp1.less" and "temp2.less" and then the files option is generated like so:

less: {
    options: {
        files: {
            'main1.css': ['temp1.less'],
            'main2.css': ['temp2.less'],
        }
    }
}

According to the grunt config documentation, this should be a valid configuration. However, when I run the package, I get the error listed in the title of this issue. I've tried various configuration formats and I've tried running as multi-task, but nothing seems to work.

I'd appreciate any help!

Option to recompile only if necessary

LESS compiling is relatively slow, it would be nice if there was an option to check if a recompilation is needed. (This would be especially useful with grunt watch)

Option to print relative file path in `dumpLineNumbers`

Using dumpLineNumbers: 'comments', CSS is currently generated with comments like this:

/* line 467, /Users/myname/path/to/project/less/file.less */

But when working on a team project that absolute path obviously differs from person to person. Each commit appears to have thousands of changes to a single CSS file even if the contributor only changed one line.

Perhaps an alternative would be to write relative paths, which would render the same for all contributors:

/* line 467, /less/file.less */

what`s wrong with less?

less: {
          development: {
            files: {
              "result.css": "source.less"
            }
          }
        }

when i type cmd "grunt less:development"
it shows me

PS D:\wwwroot\php\grunt> grunt less:development
Running "less:development" (less) task
Verifying property less.development exists in config...ERROR
>> Unable to process task.
Warning: Required config property "less.development" missing. Use --force to continue.

also with source.less in the root folder, when i run "grunt less"
ti shows

PS D:\wwwroot\php\grunt> grunt less
>> No "less" targets found.
Warning: Task "less" failed. Use --force to continue.

Error Compiling Can't Find Variable

I'm trying to compile all my less files in order. I have one file which contains all the variables, which should be included first. But I get a compile error because it can't find the variables.

I did solve this issue by first concating all the files together then running less on it but I would like to avoid that.

Here is my code:

less:{

      files:[
        "assets/css/variables.less",
        "assets/css/mixins.less",
        "assets/css/reset.less",
        "assets/css/core.less",
        "assets/vendor/**/*.css",
        "assets/css/**/*.less"
      ],

      debug: {
        files: {
          "dist/debug/css/blah.css": "<config:less.files>"
        }
      }
}

Documentation inconsistencies

The documentation is inconsistent with the example and I had to try the example in the https://github.com/gruntjs/grunt-contrib-less/blob/master/grunt.js to get it to work
Also it is unclear why I need the paths array value if I am also including it in the files array

In fact, the example that worked for me was

grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', 'less');

less: {
compile: {
options: {
paths: ['app/styles/less'],
//yuicompress: true,
//flatten: true
},
files: {
'app/styles/result.css': ['app/styles/less/application.less']
}
}
},

rewriting paths in included files

is it possible or will it be posible for included files' rules to be adjusted during compilation so that url properties can be written relative to the included file instead of relative to the parent file?

Compile event

Would it be possible to trigger an event whenever a file is compiled?

I'm looking to include this task into our company's build system and need a way to hook into this task, ideally getting the original file name and the new filename.

ie.

grunt.event.emit('less.compile', files, destFile);

Documentation inconsistencies

The documentation is inconsistent with the example and I had to try the example in the https://github.com/gruntjs/grunt-contrib-less/blob/master/grunt.js to get it to work
Also it is unclear why I need the paths array value if I am also including it in the files array

In fact, the example that worked for me was

grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', 'less');

less: {
compile: {
options: {
paths: ['app/styles/less'],
//yuicompress: true,
//flatten: true
},
files: {
'app/styles/result.css': ['app/styles/less/application.less']
}
}
},

Error: "Destination not written because compiled files were empty"

I am receiving the above error message when trying to compile a simple LESS file to CSS. My grunt config settings are:

less: {
    dev: {
        files: {
            'styles.less': 'styles.css'
        }
    }
}

Any ideas why this is happening?

I am using Grunt v0.4 and the latest version of this library (0.5.0)

@import .css files

From the Official Documentation :

You can import both css and less files. Only less files import statements are processed, css file import statements are kept as they are. If you want to import a CSS file, and don’t want LESS to process it, just use the .css extension:

Is there a way to do this now?

Possible to keep tabs and empty lines; how does optimization work?

Using LESS default output, I've noticed it converts my tabs to 2 spaces and removes empty lines (among a few other oddities).

Is there any way to make it so LESS doesn't do anything to reformat my code in terms of indentation and blank lines?

Also, what exactly does the optimization option do? I've set it to several numbers (ranging from 0 to 1000) and I haven't seen any difference in the output of my CSS. I was kinda hoping this setting would control the level of alterations LESS would do to my indentation.

Sorry to bother you with my stupid questions. 😦

updating but not creating the build file

I need to explicitly run the grunt command to create the destination css file even though it is updating and being watched henceforth.

While this itself is not a issue, it is not mentioned in the documentation and hence was a tremendous waste of time trying to figure it out

Why 0.5.0rc7?

ebff49b bumps the package's version to 0.5.0rc7 but is it true?
I'm not sure whether npm allows decreasing the version after publishing a module.

Growl support

Add growl support into this task. If it's wanted I'll see if I can get a pull request in.

dumpLineNumbers doesn't work with CSS keyframes

It converts them to:

@-webkit-keyframes spin {
  /* line 135, /local/path/to/my.less */
  @media -sass-debug-info{filename{font-family:file\:\/\/\/local\/path\/to\/my\.less}line{font-family:\00003135}}
  0% {
    -webkit-transform: rotateY(-180deg);
  }
  /* line 136, /Users/sparanoid/Git/sparanoid-start/app/assets/less/main.less */
  @media -sass-debug-info{filename{font-family:file\:\/\/\/local\/path\/to\/my\.less}line{font-family:\00003136}}
  100% {
    -webkit-transform: rotateY(0deg);
  }
}

Which Safari and Chrome don't treat it as a valid keyframes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.