Last active
March 21, 2017 02:18
-
-
Save martianyi/d124277604bb09216634 to your computer and use it in GitHub Desktop.
Gruntfile.js
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
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