Skip to content

Instantly share code, notes, and snippets.

@JoaoVagner
Created January 24, 2017 18:18
Show Gist options
  • Save JoaoVagner/2b9363568748cc774d25e2347fc27405 to your computer and use it in GitHub Desktop.
Save JoaoVagner/2b9363568748cc774d25e2347fc27405 to your computer and use it in GitHub Desktop.
// Guntfile
module.exports = function (grunt) {
'use strict';
const pathForJavascriptFiles = 'skin/frontend/enterprise/oppa/js/**/*.js',
pathForNewLayout = 'skin/frontend/oppa/default/js/*.js',
pathForJavascriptFilesHomepage = ['skin/frontend/enterprise/oppa/js/**/*.js'],
pathForCssFilesHomepage = ['skin/frontend/enterprise/oppa/css/*.css'],
dateFormat = require('dateformat'),
now = new Date(),
imageminJpegtran = require('imagemin-jpegtran'),
mozjpeg = require('imagemin-mozjpeg'),
uglifyHelper = require('./js/gruntConfig/uglify.helper.js')()
// Project configuration
grunt.initConfig({
jsFiles: pathForJavascriptFiles,
jsFilesNewLayout: pathForNewLayout,
jsFilesHomepage: pathForJavascriptFilesHomepage,
cssFiles: pathForCssFilesHomepage,
pkg: grunt.file.readJSON('package.json'),
//uglify: require('./js/gruntConfig/uglify.config')('development'),
uglify: require('./js/gruntConfig/uglify.config')('deploy'),
cssmin: grunt.file.readJSON('js/gruntConfig/cssmin.json'),
csslint: grunt.file.readJSON('js/gruntConfig/csslint.json'),
jasmine: grunt.file.readJSON('js/gruntConfig/jasmine.json'),
jshint: grunt.file.readJSON('js/gruntConfig/jshint.json'),
plato: grunt.file.readJSON('js/gruntConfig/plato.json'),
concat: grunt.file.readJSON('js/gruntConfig/concat.json'),
watch: {
// If any .less file changes in directory "build/less/" run the "less"-task.
files: [
"skin/frontend/oppa/default/scss/*/*.scss",
"skin/frontend/oppa/mobile/scss/*/*.scss"
],
tasks: ["createjscss", "uglify"]
},
imagemin: {
dynamic: {
options: {
optimizationLevel: 3,
svgoPlugins: [{removeViewBox: false}],
use: [
imageminJpegtran({progressive: false}, {arithmetic: true}, {cache: false}),
mozjpeg({quality: 80})
]
},
files: [{
expand: true,
cwd: 'media/banner',
src: ['**/*.{png,jpg,gif}'],
dest: 'media/banner/'
}]
}
},
compass: grunt.file.readJSON('js/gruntConfig/compass.json'),
svg_sprite: grunt.file.readJSON('js/gruntConfig/svgsprite.json')
});
//load all taks with grunt prefix from package.json
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
//Checa a qualidade do javascript dos arquivos verificados
grunt
.registerTask('createjs', ['uglify'])
.registerTask('checkjsquality', ['jshint'])
.registerTask('createjsdesktop', uglifyHelper.jsTasks.desktop)
//task para compilar js de lista de casamento
.registerTask('weddingjs',
['uglify:weddingjs',
'plato:wedding',
'jshint:weddingjs'
])
//task para compilar js de showroom
.registerTask('showroomjs',
['uglify:showroomjs',
'plato:showroom',
'jshint:showroomjs'
])
.registerTask('createsvg', ['svg_sprite'])
// Default tasks
.registerTask('jsTask', ['jshint', 'plato'])
.registerTask('default', ['uglify', 'cssmin'])
.registerTask('bdd', ['jasmine'])
.registerTask('homepageCss',
['concat:homepage',
'cssmin:homepage'
])
.registerTask('homepageJs',
['jshint:homepage',
'uglify:homepagejs',
'plato:homepage',
'watch:homepageJs'
])
.registerTask('optimizeImages', ['newer:imagemin'])
//tasks usadas no ambiente de produção
.registerTask('createjscss',
['svg_sprite',
'compass:createcss',
'compass:createcssmobile',
'uglify',
//'jshint:checkjs'
])
.registerTask('createcss', ['compass:createcss'])
.registerTask('devcreatecss', ['compass'])
//tasks para uso no ambiente de desenvolvimento
.registerTask('devcreatejscss',
['svg_sprite',
'compass:cleancache',
'compass:createcss',
'uglify',
'jshint:checkjs'
])
.registerTask('devshowroom',
['compass:cleancache',
'compass:createcss',
'uglify:showroomjs'
])
.registerTask('createdesktop',
uglifyHelper.pushGruntTasks('desktop',
['jshint:checkjs',
'svg_sprite:default',
'compass:createcss'
]))
.registerTask('devcreatedesktop',
uglifyHelper.pushGruntTasks('desktop',
['svg_sprite:default',
'compass:cleancache',
'compass:createcss'
]))
//MOBILE
.registerTask('createjsmobile', uglifyHelper.jsTasks.mobile)
.registerTask('createmobile',
uglifyHelper.pushGruntTasks('mobile',
['jshint:checkjs',
'svg_sprite:mobile',
'compass:createcssmobile'
]))
.registerTask('mobileCheckout', ['uglify:mobilecheckoutjs'])
.registerTask('devcreatemobile',
uglifyHelper.pushGruntTasks('mobile',
['jshint:checkjs',
'svg_sprite:mobile',
'compass:cleancachemobile',
'compass:createcssmobile'
]))
grunt.log.writeln('The task finished in ' + dateFormat(now, 'dddd, mmmm dS, yyyy, h:MM:ss TT'))
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment