User Tools

Site Tools


njsetn:converting_less_to_css_with_grunt

Préprocesser du LESS

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

Automatiser les préfixes

npm install grunt-autoprefixer --save-dev
// GruntFile.js

module.export = function(grunt) {
  grunt.initConfig({
    jshint: {
      (...)
    },
    less: {
      production: {
        files {
          "public/css/style.css": ["less/*.less"]
        },
      },
    },
    autoprefixer: {
      single_file: {
        src: "public/css/style.css",
        dest: "public/css/style.css"
      }
    },
  });
  grunt.loadNpmTasks("grunt-contrib-jshint");
  grunt.loadNpmTasks("grunt-contrib-less");
  grunt.loadNpmTasks("grunt-autoprefixer");

  grunt.registerTask("css", ["less", "autoprefixer"]);
  grunt.registerTask("default", ["jshint"]);
};

On appelle la tâche css (process+prefix) :

grunt css
njsetn/converting_less_to_css_with_grunt.txt · Last modified: 2016/03/28 23:16 by leo