Skip to content

Instantly share code, notes, and snippets.

@mrhieu
Created June 6, 2018 08:55
Show Gist options
  • Save mrhieu/a7ba21deae4c5183e5f6b41b0bbd2817 to your computer and use it in GitHub Desktop.
Save mrhieu/a7ba21deae4c5183e5f6b41b0bbd2817 to your computer and use it in GitHub Desktop.
[Medium] Prevent Annoying Template Caching in AngularJS 1.x
...
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'gitinfo',
'clean:server',
'ngconstant',
...
]);
});
...
module.exports = function(grunt, options) {
var buildEnvironment = grunt.config('env');
return {
options: {
name: 'ngConstantEnv',
dest: '.tmp/scripts/env.js'
},
// Environment targets
environment: {
wrap: '"use strict";\n\n <%= __ngModule %>',
constants: {
ENV: {
name: buildEnvironment,
baseUrl: require('../app.json')[buildEnvironment]['baseUrl'],
version: require('../package.json').version,
build: '<%= new Date(gitinfo.local.branch.current.lastCommitTime).getTime() %>'
}
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment