Created
July 16, 2015 14:05
-
-
Save jonasmello/72f46ce83309092c48b8 to your computer and use it in GitHub Desktop.
Configuração do Grunt
This file contains hidden or 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
var mozjpeg = require('imagemin-mozjpeg'); | |
module.exports = function (grunt) { | |
var json = { | |
js: { | |
src: [ | |
'src/js/jquery-1.11.2.js', | |
'src/js/SmoothScroll.js', | |
'src/js/main.js', | |
], | |
dest: 'assets/js/main.js', | |
min: 'assets/js/main.min.js' | |
}, | |
styl: { | |
src: [ | |
'src/styl/main.styl' | |
], | |
dest: 'assets/css/main.css', | |
min: 'assets/css/main.min.css' | |
} | |
}; | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
concat: { | |
options: { | |
separator: ';', | |
sourceMap: true, | |
}, | |
dist: { | |
src: json.js.src, | |
dest: json.js.dest | |
}, | |
}, | |
uglify: { | |
dist: { | |
options: { | |
// sourceMap: true, | |
compress: { | |
drop_console: true | |
} | |
}, | |
src: json.js.src, | |
dest: json.js.min | |
} | |
}, | |
stylus: { | |
dev: { | |
options: { | |
compress: false, | |
sourcemap: { | |
inline: true | |
} | |
}, | |
src: json.styl.src, | |
dest: json.styl.dest | |
}, | |
prod: { | |
src: json.styl.src, | |
dest: json.styl.min | |
} | |
}, | |
imagemin: { // Task | |
dynamic: { // Another target | |
files: [{ | |
expand: true, // Enable dynamic expansion | |
cwd: 'src/img/', // Src matches are relative to this path | |
src: ['*.{png,jpg,gif}'], // Actual patterns to match | |
dest: 'assets/img/' // Destination path prefix | |
}] | |
} | |
}, | |
sprite: { | |
spritesheet: { | |
src: "src/img/sprites/*.png", | |
dest: "assets/img/sprite.png", | |
destCss: 'src/styl/sprites.styl', | |
cssTemplate: 'src/styl/sprites.styl.tpl', | |
padding: 10, | |
algorithm: "binary-tree", | |
imgPath: "../img/sprite.png" | |
} | |
}, | |
// gzip assets 1-to-1 for production | |
compress: { | |
main: { | |
options: { | |
archive: 'gol.zip' | |
}, | |
expand: true, | |
cwd: '.', | |
src: ['assets/**/*', 'index.html'], | |
dest: '.' | |
} | |
}, | |
watch: { | |
configFiles: { | |
files: ['Gruntfile.js'], | |
options: { | |
reload: true | |
} | |
}, | |
js: { | |
files: [json.js.src], | |
tasks: ['js'], | |
options: { | |
spawn: false, | |
}, | |
}, | |
css: { | |
files: ['src/styl/**/*.styl'], | |
tasks: ['css'], | |
options: { | |
spawn: false, | |
}, | |
}, | |
img: { | |
files: ['src/img/*.{png,jpg,gif}'], | |
tasks: ['imagemin'], | |
options: { | |
spawn: false, | |
}, | |
}, | |
sprite: { | |
files: ['src/img/sprites/*.{png,jpg}'], | |
tasks: ['s'], | |
options: { | |
spawn: true, | |
}, | |
}, | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-stylus'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
grunt.loadNpmTasks('grunt-spritesmith'); | |
grunt.loadNpmTasks('grunt-contrib-compress'); | |
grunt.registerTask('zip', ['compress']); | |
grunt.registerTask('js', ['concat', 'uglify']); | |
grunt.registerTask('css', ['stylus']); | |
grunt.registerTask('s', ['sprite', 'css']); | |
grunt.registerTask('w', ['sprite', 'imagemin', 'js', 'css', 'watch']); | |
grunt.registerTask('default', ['js', 'css']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment