Last active
December 23, 2015 00:49
-
-
Save larodiel/6555779 to your computer and use it in GitHub Desktop.
Basic congif. grunt.js file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
'use strict'; | |
var imagePath = "../htdocs/images"; | |
var jsPath = "../htdocs/js"; | |
var uglifyOptions = { | |
beautify: false, | |
report: "min", | |
mangle: { | |
except: ['jQuery'] | |
}, | |
compress: { | |
global_defs: { | |
"DEBUG": false | |
}/*, | |
dead_code: true*/ | |
} | |
} | |
var gruntConfig = { | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
globals: { | |
options: uglifyOptions, | |
files: { | |
'../htdocs/js/globals.js': [ | |
"../htdocs/source/js/libs/jquery-1.8.3.min.js", | |
"../htdocs/source/js/libs/config.js", | |
"../htdocs/source/js/libs/plugins.js", | |
"../htdocs/source/js/libs/utils.js", | |
"../htdocs/source/js/libs/cookie.utils.js", | |
"../htdocs/source/js/libs/cartFlutuante.js", | |
"../htdocs/source/js/libs/acec.js", | |
"../htdocs/source/js/libs/global.js", | |
"../htdocs/source/js/libs/social-scripts.js", | |
"../htdocs/source/js/events-common.js" | |
] | |
} | |
}, | |
products: { | |
options: uglifyOptions, | |
files: { | |
'../htdocs/js/products.js': [ | |
"../htdocs/source/js/products/events-comments.js", | |
"../htdocs/source/js/products/products.js", | |
"../htdocs/source/js/products/productUtils.js", | |
"../htdocs/source/js/products/product_palette.js" | |
] | |
} | |
}, | |
address: { | |
options: uglifyOptions, | |
files: { | |
'../htdocs/js/address.js': [ | |
"../htdocs/source/js/libs/jquery-ui-1.10.3.js", | |
"../htdocs/source/js/libs/jquery-ui-i18n.js", | |
"../htdocs/source/js/scheduledDeliveryClient.js", | |
"../htdocs/source/js/enderecos.js" | |
] | |
} | |
}, | |
dynamic_mappings: { | |
options: uglifyOptions, | |
files: [ | |
{ | |
expand: true, // Enable dynamic expansion. | |
cwd: '../htdocs/source/js/', // Src matches are relative to this path. | |
src: ['*.js', '!globals.js', '!products.js'], // Actual pattern(s) to match. | |
dest: '../htdocs/js', // Destination path prefix. | |
ext: '.js' // Dest filepaths will have this extension. | |
} | |
] | |
} | |
}, | |
//O Objetivo do concat neste caso é somente mover o arquivo para manter o padrao | |
/*concat: { | |
options: { | |
separator: ';' | |
}, | |
globals: { | |
src: | |
[ | |
"../htdocs/source/js/libs/jquery-1.8.3.min.js", | |
"../htdocs/source/js/libs/plugins.js", | |
"../htdocs/source/js/libs/utils.js", | |
"../htdocs/source/js/libs/cookie.utils.js", | |
"../htdocs/source/js/libs/cartFlutuante.js", | |
"../htdocs/source/js/libs/acec.js", | |
"../htdocs/source/js/libs/global.js", | |
"../htdocs/source/js/libs/social-scripts.js" | |
], | |
dest: '../htdocs/js/globals.js' | |
}, | |
products: { | |
src: | |
[ | |
"../htdocs/source/js/products/events-comments.js", | |
"../htdocs/source/js/products/products.js", | |
"../htdocs/source/js/products/product_palette.js", | |
"../htdocs/source/js/products/productUtils.js" | |
], | |
dest: '../htdocs/js/products.js' | |
} | |
},*/ | |
imagemin: { | |
options: { | |
optimizationLevel: 3 | |
}, | |
dynamic: { | |
files: [{ | |
expand: true, | |
cwd: '../htdocs/source/images', | |
src: ['**/*.{png,jpg,gif}'], | |
dest: imagePath | |
}] | |
} | |
} | |
}; | |
grunt.initConfig(gruntConfig); | |
grunt.event.on('watch', function(action, filepath, target) { | |
grunt.log.writeln(target + ': ' + filepath + ' foi ' + action); | |
}); | |
var keys = Object.keys(gruntConfig); | |
var tasks = []; | |
for(var i = 1, l = keys.length; i < l; i++) { | |
tasks.push(keys[i]); | |
} | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
//Optimizador de imagem | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
grunt.registerTask('default', tasks); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment