generator-mupal
Version:
Download Drupal and some recommended modules
152 lines (145 loc) • 5.36 kB
JavaScript
module.exports = function (grunt) {
'use strict';
require('time-grunt')(grunt);
var svgo = require('imagemin-svgo');
// Project configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= props.license %> */\n',
// Task configuration
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
}
},
uglify: {
options: {
banner: '<%= banner %>'
}
},
jshint: {
options: {
node: true,
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
eqnull: true,
globals: { jQuery: true, angular: true, window: true, navigator: true },
boss: true
},
gruntfile: {
src: 'Gruntfile.js'
},
theme: {
src: [
"<%= pkg.theme %>/js/**/*.js",
"!<%= pkg.theme %>/js/vendor/**/*",
"!<%= pkg.theme %>/js/**/*.min.js"
]
}
},
less: {
options: {
compress: true,
cleancss: true,
ieCompat: false
},
main: {
files: {
"<%= pkg.theme %>/css/style.css": "<%= pkg.theme %>/less/style.less"
}
}
},
imagemin: {
png: {
files: [{
expand: true, // Enable dynamic expansion
cwd: '<%= pkg.theme %>/img/', // Src matches are relative to this path
src: ['**/*.png'], // Actual patterns to match
dest: '<%= pkg.theme %>/img/' , // Destination path prefix
ext: '.min.png'
}]
},
jpg: {
files: [{
expand: true, // Enable dynamic expansion
cwd: '<%= pkg.theme %>/img/', // Src matches are relative to this path
src: ['**/*.jpg'], // Actual patterns to match
dest: '<%= pkg.theme %>/img/' , // Destination path prefix
ext: '.min.jpg'
}]
},
gif: {
files: [{
expand: true, // Enable dynamic expansion
cwd: '<%= pkg.theme %>/img/', // Src matches are relative to this path
src: ['**/*.gif'], // Actual patterns to match
dest: '<%= pkg.theme %>/img/' , // Destination path prefix
ext: '.min.gif'
}]
},
svg: {
options: {
use: [svgo()]
},
files: [{
expand: true, // Enable dynamic expansion
cwd: '<%= pkg.theme %>/img/', // Src matches are relative to this path
src: ['**/*.svg'], // Actual patterns to match
dest: '<%= pkg.theme %>/img/' , // Destination path prefix
ext: '.min.svg'
}]
}
},
watch: {
options: {
interrupt: true,
atBegin: true
},
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
js: {
files: '<%= jshint.theme.src %>',
tasks: ['jshint:theme']
},
less: {
files: '<%= pkg.theme %>/less/**/*.less',
tasks: ['less']
},
imagemin: {
files: [
'<%= pkg.theme %>/img/**/*.png',
'<%= pkg.theme %>/img/**/*.jpg',
'<%= pkg.theme %>/img/**/*.gif',
'<%= pkg.theme %>/img/**/*.svg',
'!<%= pkg.theme %>/img/**/*.min.*'
],
tasks: ['imagemin']
}
}
});
// These plugins provide necessary tasks
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-newer');
// Default task
grunt.registerTask('default', ['jshint', 'newer:imagemin', 'less']);
};