Reputation: 137
I'm building an application with AngularJS and Grunt, and i have a particular line of code that i would like to use only in the "dist" version of my app, is there a way to tell grunt to delete that line of code unless i run 'grunt build'?
angular
.module('myModule', [
'ngResource',
'ngRoute',
'ngSanitize'
])
.config(['$routeProvider', '$locationProvider',function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
$locationProvider.hashPrefix('!');
/** Insert code if 'grunt build' **/
$locationProvider.html5Mode(true);
/** End of code inserted for build **/
}]);
Upvotes: 0
Views: 54
Reputation: 10874
You could use a task like grunt-string-replace (https://www.npmjs.org/package/grunt-string-replace) and then simply leave a comment in then replace that comment with what you want on build.
options: {
replacements: [{
pattern: '// insert code here',
replacement: '$locationProvider.html5Mode(true);'
}]
}
Upvotes: 2