Skip to content

Instantly share code, notes, and snippets.

@martianyi
Last active March 21, 2017 02:18
Show Gist options
  • Save martianyi/d124277604bb09216634 to your computer and use it in GitHub Desktop.
Save martianyi/d124277604bb09216634 to your computer and use it in GitHub Desktop.
Gruntfile.js
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
ngtemplates: {
clwmcTemplates: {
cwd: 'src',
src: ['*.html', '**/*.html'],
dest: 'src/common/tpl/templates.js',
options: {
standalone: true
}
}
},
concat: {
dist: {
src: ['src/app.js', 'src/**/*.js'],
dest: '.tmp/js/<%= pkg.name %>.js'
}
},
ngAnnotate: {
options: {
singleQuotes: true
},
dist: {
files: {
'.tmp/js/<%= pkg.name %>.annotated.js': ['<%= concat.dist.dest %>']
}
}
},
uglify: {
options: {
// the banner is inserted at the top of the output
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'assets/js/<%= pkg.name %>.min.js': '.tmp/js/<%= pkg.name %>.annotated.js'
}
}
},
// Extract pot from html and js
nggettext_extract: {
pot: {
files: {
'po/template.pot': ['src/**/*.html', 'src/**/*.js']
}
}
},
// Compile to JSON file
nggettext_compile: {
all: {
options: {
format: "json"
},
files: [
{
expand: true,
dot: true,
cwd: "po",
dest: "src/common/resources/translation",
src: ["*.po"],
ext: ".json"
}
]
}
}
});
grunt.registerTask('build', [
'concat',
'ngAnnotate',
'uglify',
'nggettext_extract',
'nggettext_compile',
]);
grunt.registerTask('deploy', [
'ngtemplates',
'concat',
'ngAnnotate',
'uglify'
]);
grunt.registerTask('default', [
'deploy'
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment