Skip to content

Instantly share code, notes, and snippets.

@anareyna
Last active August 29, 2015 14:01
Show Gist options
  • Save anareyna/85a4084f2f0bf0c4bfe3 to your computer and use it in GitHub Desktop.
Save anareyna/85a4084f2f0bf0c4bfe3 to your computer and use it in GitHub Desktop.
Gruntfile.js ofertop
module.exports = function(grunt) {
var path = {
jadeflux : "jadeflux/",
styflux : "styl/",
coffee : "coffee/",
public : "../public/",
static : "../public/static/o/"
};
// Configuración para proyectos y tareas
grunt.initConfig({
// clean
clean: {
options: {
force: true
},
build: {
src: [path.public+"layout/", path.public+"modules/", path.static+"css/", path.static+"js/source/", path.static+"js/dist/*.js", path.static+"js/dist/modules/"]
}
},
//jade
jade: {
frontend: {
options: {
pretty: true
},
files: [{
expand: true,
cwd: path.jadeflux,
src: ['**/*.jade', '!**/_*.jade', '!_**/*.jade', '!_**/_*.jade'],
dest: path.public,
ext: '.phtml'
}]
}
/*,
backend: {
options: {
pretty: true
},
files: [{
expand: true,
cwd: 'jadeflux/',
src: [''],
dest: '../view/',
ext: '.phtml'
}]
}
*/
},
//stylus
stylus: {
compile: {
options: {
paths: [path.styflux],
compress: false,
linenos: false
},
files: [{
expand: true,
cwd: path.styflux,
src: ['**/*.styl', '!_**/*.styl' , '!**/_**/*.styl'],
dest: path.static+'css/',
ext: '.css'
}]
}
},
//coffee
coffee: {
scripts: {
options: {
bare: true
},
expand: true,
cwd: path.coffee+'scripts/',
src: ['**/*.coffee', '!**/_*.coffee'],
dest: path.static+'js/source/',
ext: '.js'
},
libs: {
options: {
bare: true
},
expand: true,
cwd: path.coffee+'libs/',
src: ['**/*.coffee', '!**/_*.coffee'],
dest: path.static+'js/source/libs/',
ext: '.js'
},
},
//concat
concat: {
options: {
stripBanners: false
}
},
//copy
copy: {
libs: {
options: {
},
expand: true,
cwd: path.static+'js/source/libs/',
src: ['**/*.js'],
dest: path.static+'js/dist/libs/',
ext: '.js'
},
},
//jshint
jshint: {
options: {
jshintrc : 'grunt/.jshintrc',
"smarttabs" : true
},
js: [path.static+'js/dist/**/*.js', '!'+path.static+'js/dist/libs/*.js', '!'+path.static+'js/dist/libs/jquery/*.js', '!'+path.static+'js/dist/libs/utils/*.js']
},
// sprites
// documentation: https://github.com/Ensighten/grunt-spritesmith
// agregar dependencia en package.json --> "grunt-spritesmith": "^1.26.0"
sprite:{
all: {
src: path.static+'img/sprites/*.png',
destImg: path.static+'img/sprite.png',
destCSS: path.styflux+'_mixins/sprites.styl',
algorithm: 'binary-tree',
imgPath: '../../../img/sprite.png', // solo en caso de una ruta especifica para el .styl generado
}
},
// watchers
watch: {
jade: {
files: [path.styflux+'**/*.jade'],
tasks: ['jadefe'],
options: {
pretty: true,
interrupt: true
}
},
coffee: {
files: path.coffee+'**/*.coffee',
tasks: ['js'],
options: {
interrupt: true,
livereload: {
port: 35729
}
}
},
stylus: {
files: [path.styflux+'**/*.styl'],
tasks: ['stylus_path', 'stylus_version', 'newer:stylus'],
options: {
interrupt: true,
pretty: true
}
}
}
});
// Cargar las tareas
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-spritesmith');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.task.loadTasks('grunt/custom_tasks/');
// registrando tareas
grunt.registerTask('cafe', ['newer:coffee']);
grunt.registerTask('js_source', ['concatenation', 'newer:concat', 'newer:copy']);
grunt.registerTask('javascript', ['js_source', 'newer:jshint']);
grunt.registerTask('js', ['cafe', 'javascript']);
grunt.registerTask('jadefe', ['uncomment', 'newer:jade:frontend']);
grunt.registerTask('jadebe', ['comment', 'newer:jade:backend']);
grunt.registerTask('styles', ['stylus_path','stylus_version', 'stylus']);
grunt.registerTask('jscript', ['coffee', 'concatenation', 'concat', 'copy', 'jshint']);
grunt.registerTask('all', ['clean', 'styles', 'jade:frontend', 'jscript']);
// Tarea por defecto.
grunt.registerTask('default', ['stylus_path','stylus_version', 'newer:stylus', 'jadefe', 'js']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment