Skip to content

feat(build) : replace string at build #757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -943,7 +958,8 @@ module.exports = function (grunt) {
'cssmin',
'uglify',
'rev',
'usemin'
'usemin',
'replace'
]);

grunt.registerTask('default', [
Expand Down
1 change: 1 addition & 0 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions app/templates/replace_at_build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = [
{
match: 'UA-XXXXX-X',
replacement: 'GoogleID'
},
{
match: '/api/',
replacement: '/api/'
},
{
match: '/auth/',
replacement: '/auth/'
}
]

3 changes: 2 additions & 1 deletion test/test-file-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down