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

Sass sourcemaps only in dev environment #77

Closed cachaito closed 10 years ago

cachaito commented 10 years ago

Hi everyone! This config works great, but how easily turn off Sass source maps feature when i use build task (this settings works on default and build tasks the same)

autoprefixer: {
    options: {
        browsers: ['last 1 versions'],
        map: true
    },
    dist: {
        files: [{
            expand: true,
            cwd: '.tmp/styles',
            src: '{,*/}*.css',
            dest: '.tmp/styles'
        }]
    }
}
nDmitry commented 10 years ago

Just remove the map option.

(You should also disable sourcemaps in your Sass plugin options.)

cachaito commented 10 years ago

Sorry if I was not understood correctly. I have two tasks in Gruntfile.js build and default. In default i need this 'map: true' option but when I'm making a dist package for a client (build task), there is no need for creating .map for .css files.

nDmitry commented 10 years ago
autoprefixer: {
    options: {
        browsers: ['last 1 versions'],
    },
    dev: {
        options: {
            map: true
        },
        files: [{
            expand: true,
            cwd: '.tmp/styles',
            src: '{,*/}*.css',
            dest: '.tmp/styles'
        }]
    }
    dist: {
        files: [{
            expand: true,
            cwd: '.tmp/styles',
            src: '{,*/}*.css',
            dest: '.tmp/styles'
        }]
    }
}
'autoprefixer:dev' // will call ‘dev’ target
'autoprefixer' // will call ‘dist’ target (default)

Here's more about targets and task- or target-specific options: http://gruntjs.com/configuring-tasks#task-configuration-and-targets

cachaito commented 10 years ago

Thank You for detailed answer Dmitry. I just wanted to avoid this syntax while "files: [{...}]" paths are the same for those tasks...

nDmitry commented 10 years ago

Yeah it's not DRY, but Grunt only allows to have common options, everything else must be per target.

You can use a shorter syntax for this particular case though since you specify the same destination:

dist: {
    src: '.tmp/styles/{,*/}*.css'
}
cachaito commented 10 years ago

Again, thank You Dmitry for clearing this case.

Have a nice day!