diff --git a/app/templates/Gruntfile.js b/app/templates/Gruntfile.js index 6755db958..77c7edff0 100644 --- a/app/templates/Gruntfile.js +++ b/app/templates/Gruntfile.js @@ -17,7 +17,8 @@ module.exports = function (grunt) { cdnify: 'grunt-google-cdn', protractor: 'grunt-protractor-runner', buildcontrol: 'grunt-build-control', - istanbul_check_coverage: 'grunt-mocha-istanbul' + istanbul_check_coverage: 'grunt-mocha-istanbul', + replace: 'grunt-replace', }); // Time how long tasks take. Can help when optimizing build times @@ -433,6 +434,20 @@ module.exports = function (grunt) { } }, + // replace string at build according to replace_at_build.js + replace: { + dist: { + options: { + patterns: require("./replace_at_build"), + usePrefix: false, + noProcess : ['<%%= yeoman.dist %>/client/bower_components/**/*.*', '<%%= yeoman.dist %>/client/**/*.png', '<%%= yeoman.dist %>/client/**/*.ico', '<%%= yeoman.dist %>/client/**/*.txt'], + }, + files: [ + {expand: true, flatten: false, src: ['<%%= yeoman.dist %>/client/**/*.*']} + ] + } + }, + buildcontrol: { options: { dir: 'dist', @@ -943,7 +958,8 @@ module.exports = function (grunt) { 'cssmin', 'uglify', 'rev', - 'usemin' + 'usemin', + 'replace' ]); grunt.registerTask('default', [ diff --git a/app/templates/_package.json b/app/templates/_package.json index 1666ea8b0..df8b717b0 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -53,6 +53,7 @@ "grunt-jscs": "~0.7.1", "grunt-newer": "~0.7.0", "grunt-ng-annotate": "^0.2.3", + "grunt-replace": "^0.8.0", "grunt-rev": "~0.1.0", "grunt-svgmin": "~0.4.0", "grunt-usemin": "~2.1.1", diff --git a/app/templates/replace_at_build.js b/app/templates/replace_at_build.js new file mode 100644 index 000000000..519e7eb49 --- /dev/null +++ b/app/templates/replace_at_build.js @@ -0,0 +1,15 @@ +module.exports = [ + { + match: 'UA-XXXXX-X', + replacement: 'GoogleID' + }, + { + match: '/api/', + replacement: '/api/' + }, + { + match: '/auth/', + replacement: '/auth/' + } + ] + diff --git a/test/test-file-creation.js b/test/test-file-creation.js index 0e227efef..13ccedf04 100644 --- a/test/test-file-creation.js +++ b/test/test-file-creation.js @@ -206,7 +206,8 @@ describe('angular-fullstack generator', function () { 'bower.json', 'karma.conf.js', 'mocha.conf.js', - 'protractor.conf.js' + 'protractor.conf.js', + 'replace_at_build.js' ]); /* Ui-Router */