GRUNT [LESS, Autoprefix, Sourcemap, Minify]
{
"name": "Project",
"version": "0.1.0",
"devDependencies": {
"grunt": "*",
"grunt-autoprefixer" : "*",
"grunt-contrib-watch": "*",
"grunt-contrib-less": "*",
"grunt-contrib-cssmin" : "*",
"grunt-contrib-copy" : "*",
"grunt-lesslint" : "*"
}
}
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
lesswatch: {
files: ['src/less/**'],
tasks: ['lesswatch']
}
},
lesslint: {
src: ['src/less/*.less']
},
less: {
lesswatch: {
options: {
sourceMap: true,
sourceMapFilename: 'build/style/style.css.map',
},
files: {
'build/style/style.css': 'src/less/style.less'
}
}
},
autoprefixer: {
lessprefix: {
options: {
map: true,
browsers: ['last 2 versions', 'ie 9']
},
src: 'build/style/style.css',
dest: 'build/style/style.css'
}
},
cssmin: {
finalize: {
files: [{
expand: true,
cwd: 'build/style',
src: ['*.css', '!*.min.css'],
dest: 'build/style',
ext: '.min.css'
}]
}
},
copy: {
fonts: {
expand: true,
cwd: 'src/less/fonts/',
src: ['**'],
dest: 'build/style/fonts'
},
bower: {
files: [
{
expand: true,
cwd: 'bower_components/jquery/dist/',
src: 'jquery.min.js',
dest: 'build/js/vendor'
}, {
expand: true,
cwd: 'bower_components/fontawesome/css/',
src: 'font-awesome.css',
dest: 'src/less/third'
}, {
expand: true,
cwd: 'bower_components/fontawesome/fonts/',
src: ['**'],
dest: 'src/less/fonts'
}
]
}
}
});
// Plugins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-lesslint');
// Register Default GRUNT Task
grunt.registerTask('default', ['lesswatch']);
// First
grunt.registerTask('create', ['copy:fonts','copy:bower']);
// LESS Tasks
grunt.registerTask('lesswatch', ['less:lesswatch', 'lesslint', 'autoprefixer:lessprefix', 'cssmin:finalize']);
};