nDmitry / grunt-autoprefixer

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

Wrong sample with multiple files #109

Closed tucq88 closed 9 years ago

tucq88 commented 9 years ago
// prefix all files
    multiple_files: [{
      expand: true,
      flatten: true,
      src: 'src/css/*.css', // -> src/css/file1.css, src/css/file2.css
      dest: 'dest/css/' // -> dest/css/file1.css, dest/css/file2.css
    }],

Character [ and ] are redundant. I got Warning: undefined is not a function if include those in my Gruntfile.js. After remove that it works like a charm.

robertwbradford commented 9 years ago

+1

Looks like it might have been just copied and modified from http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically.

This would also work:

    autoprefixer: {
      multiple_files: {
        files: [{
          expand: true,
          flatten: true,
          src: 'src/css/*.css',
          dest: 'dest/css/'
        }]
      }
    },
corysimmons commented 9 years ago

:+1:

the-dijkstra commented 8 years ago
    //The autoprefixer task
    autoprefixer: {
        options: {
            browsers: ['last 2 versions', 'ie 8', 'ie 9', '> 1%']
        },
        target: {
            expand: true,
            flatten: true,
            src: 'css/*.css',
            dest: 'css/'
        }
    },
orso081980 commented 7 years ago

I'm setting a grunt file for a task. My goal is to create a css file from a sass file (scss) and add an autoprefix to all the proprieties which require so. Initially I used the propriety multifiles but it didn't work, so now I'm using the target propriety that works fine, but my problem is, even if I target the very same file, it will create another file in my folder where I put all my sass files.

So far my file is the following:

module.exports = function (grunt) {

grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    sass: {
        dev: {
            options: {
                style: 'expanded',
                sourcemap: 'none',
            },
            files: {
                '../style.css': 'scss/style.scss'
            }
        },
        dist: {
            options: {
                style: 'compressed',
                sourcemap: 'none',
            },
            files: {
                '../style-min.css': 'scss/style.scss'
            }
        }
    },
    autoprefixer: {
        options: {
            browsers: ['last 6 versions']
        },
        target: {
            expand: true,
            flatten: true,
            src: '../style.css',
            dest: ''
        }
    },
    watch: {
        css: {
            files: '**/*.scss',
            tasks: ['sass', 'autoprefixer']
        }
    },
});

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

} My goal is to set up a global task for all my css files, like so:

target: { expand: true, flatten: true, src: '*.css', dest: '' } but it is not working even if I try something like:

target: { expand: true, flatten: true, src: '../*.css', dest: '' } Does anyone know why?