Skip to content

Instantly share code, notes, and snippets.

@JeansBolong
Last active August 18, 2017 09:09
Show Gist options
  • Save JeansBolong/1644d5e87023acadf462c7f6561680bd to your computer and use it in GitHub Desktop.
Save JeansBolong/1644d5e87023acadf462c7f6561680bd to your computer and use it in GitHub Desktop.
GRUNT TASK
module.exports = function(grunt){
grunt.initConfig({
copy:{
css:{
files:[
{
cwd: 'folder/source/file',
src: '**/*.css',
dest: 'folder/target/',
expand: true
}
]
}
},
watch:{
options: {
spawn: false,
cwd: 'folder/yg/di/watch/'
},
css: {
files: ['**/*.*'],
tasks: ['newer:copy:css']
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-newer');
grunt.registerTask('build', ['watch:css']);
};
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
sourcemap: 'file',
style: 'expanded'
},
files: [{
expand: true,
cwd: 'source/folder',
src: ['**/*.scss'],
dest: 'destination/folder',
ext: '.css'
}]
}
},
postcss: {
options: {
map: true,
processors: [
require('autoprefixer')({
browsers: ['last 2 versions']
})
]
},
dist: {
src: 'destination/file'
}
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'source/folder',
src: ['*.css', '!*.min.css'],
dest: 'destination/folder',
ext: '.min.css'
}]
}
},
watch: {
css: {
files: '**/*.scss',
tasks: ['sass','postcss','cssmin']
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['watch']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment