i used can-compile NodeJS module that compiles CanJS EJS views into a single JavaScript file for lightning fast production apps in my project. (i use canjs, requirejs, ejs.js for templates):
i followed these instructions to set my grunt task http://ift.tt/12j76oa
my Gruntfile.js :
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
cancompile: {
options: {
version: '1.1.8',
wrapper: 'define(["can/view/ejs"], function(can) { {{{content}}} });'
},
dist: {
src: ['**/*.ejs', '!node_modules/**/*.ejs', '!www-built/**/*.ejs'],
dest: 'www-built/js/views.production.js'
}
},
uglify: {
//configuracion uglify
options: {
mangle: false,
compress: {
drop_console: true
},
preserveComments : false
},
js: {
files: [{
cwd: 'www-built/js/', // ruta de nuestro javascript fuente
expand: false, // ingresar a las subcarpetas
src: 'views.production.js', // patrón relativo a cwd
dest: 'www-built/js/' // destino de los archivos compresos
}]
}
}
});
/*carichiamo i moduli*/
grunt.loadNpmTasks('can-compile');
grunt.loadNpmTasks('grunt-contrib-uglify');
/*registriamo il task*/
grunt.registerTask('default', ['cancompile, uglify']);
};
the grunt task work, and it create the single js file compiled, but when i run the require build it doesn't include the generated file with the views in production.
i got this error :
can.view: No template or empty emplate:js/app/common/calendar/views/init.ejs
Aucun commentaire:
Enregistrer un commentaire