Closed tucq88 closed 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/'
}]
}
},
:+1:
//The autoprefixer task
autoprefixer: {
options: {
browsers: ['last 2 versions', 'ie 8', 'ie 9', '> 1%']
},
target: {
expand: true,
flatten: true,
src: 'css/*.css',
dest: 'css/'
}
},
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?
Character
[
and]
are redundant. I gotWarning: undefined is not a function
if include those in my Gruntfile.js. After remove that it works like a charm.