K
K
Koreetz Koreetz2016-10-13 15:30:16
Grunt.js
Koreetz Koreetz, 2016-10-13 15:30:16

How to setup grunt-autoprefixer for Grunt?

Good day everyone.
Can't configure grunt-autoprefixer for Grunt!
I run the script but nothing happens.
The code below is written which is in Gruntfile.js

"use strict";

module.exports = function(grunt) {
  grunt.loadNpmTasks("grunt-browser-sync");
  grunt.loadNpmTasks("grunt-contrib-watch");
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  grunt.initConfig({

    browserSync: {
      server: {
        bsFiles: {
          src: [
            "*.html",
            "css/*.css"
          ]
        },
        options: {
          server: ".",
          watchTask: true,
          notify: false,
          open: true,
          ui: false
        }
      }
    },

    autoprefixer: {
    options: {
        browsers: ["last 2 versions", "Firefox ESR", "Opera 12.1"],
    },
    files: {
        "css/style.css": ["css/style.css"]
      }
    },

  uglify: {
    dist: {
      files: {
        'js/script.min.js': ['js/script.js']
      }
    }
  },
    cssmin: {
          combine: {
            files: {
              'css/style.min.css': [
                'css/style.css'
                ]
            }
          }
        },
    watch: {
      options: {
        livereload: true
      },
      scripts: {
            files: ['js/*.js'],
            tasks: ['uglify'],
            options: {
                spawn: false
            }
        },
      style: {
        files: ["css/**/*.css"],
        tasks: ["cssmin"],
        options: {
          spawn: false
        }
      }
    }
  });

  grunt.registerTask("default", ["browserSync", "watch", "autoprefixer", "uglify", "cssmin"]);
};

What did I do wrong?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
surid, 2016-10-13
@shnopik87

Add "autoprefixer" task to watch.style

watch: {
  ...
  style: {
    ...
    tasks: ["autoprefixer", "cssmin"]
    ...
  }
  ...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question