nDmitry / grunt-autoprefixer

Parse CSS and add vendor-prefixed CSS properties using the Can I Use database. Based on Autoprefixer.
MIT License
794 stars 60 forks source link

grunt-autoprefixer + grunt-contrib-watch (livereload) + grunt-sass = livereload "catches" every other time #126

Open pipejesus opened 8 years ago

pipejesus commented 8 years ago

Hi, after adding grunt-autoprefixer to my watch task 2 things broke:

  1. Livereload reloads my page every other time (one save: no reload, next save: reloads - always this way)
  2. The generated sourcemaps reference wrong lines

My configuration:

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        autoprefixer: {
          options: {
            browsers: ['last 20 versions'],
            map: true
          },
          dist: {
            expand: true,
            flatten: true,
            src: 'css/*.css',
            dest: 'css/'
          }
        },
        watch: {
            sass: {
                files: ['sass/**/*.{scss,sass}'],
                tasks: ['sass:dist', 'autoprefixer:dist'],
            },
            livereload: {
                files: ['**/*.html', '**/*.php', 'js/**/*.{js,json}', 'css/**/*.css','img/**/*.{png,jpg,jpeg,gif,webp,svg}'],
                options: {
                    livereload: true
                }
            }
        },
        sass: {
            options: {
                sourceMap: true,
                outputStyle: 'expanded',
                precision: 8
            },
            dist: {
                files : [
                    {
                        src : ['**/*.scss'], //,'!**/_*.scss' 
                        cwd : 'sass',
                        dest : 'css',
                        ext : '.css',
                        expand : true
                    }
                ],
            }
        }
    });

    grunt.registerTask('default', ['sass:dist', 'watch']);
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-autoprefixer');

};