Last active
December 21, 2015 05:49
-
-
Save vtanathip/6260183 to your computer and use it in GitHub Desktop.
grunt configuration for profile management with grunt replace plugin ref: https://github.com/outaTiME/grunt-replace
This file contains 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
replace: { | |
local:{ | |
options:{ | |
variables:{ | |
'host':'http://localhost' | |
}, | |
prefix: '@@' | |
}, | |
files: [ | |
{src: ['app/scripts/services/services.js'], dest: 'app/scripts/prod/services/services.js'} | |
] | |
}, | |
dist:{ | |
options:{ | |
variables:{ | |
'host':'http://some.dist.host.com' | |
}, | |
prefix: '@@' | |
}, | |
files: [ | |
{src: ['app/scripts/services/services.js'], dest: 'app/scripts/prod/services/services.js'} | |
] | |
} | |
} | |
//and declare var in javascript files (in this case services.js) | |
var host = "@@host"; |
This file contains 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
grunt replace:dist | |
grunt replace:local |
This file contains 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
//for running server | |
grunt.registerTask('server', function (target) { | |
if (target === 'dist') { | |
return grunt.task.run([ | |
//add task to replace it (dist) | |
'replace:dist', | |
'build', | |
'open', | |
'connect:dist:keepalive', | |
'replace:dist' | |
]); | |
} | |
grunt.task.run([ | |
//add task to replace it (local) | |
'replace:local', | |
'clean:server', | |
'concurrent:server', | |
'connect:livereload', | |
'open', | |
'watch' | |
]); | |
}); |
This file contains 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
//for maven-yeo-plugin or when we want to deploy it | |
grunt.registerTask('build', [ | |
//and don't forget to add this task to build process | |
'replace:dist', | |
'clean:dist', | |
'useminPrepare', | |
'concurrent:dist', | |
'concat', | |
'copy', | |
'cdnify', | |
'ngmin', | |
'cssmin', | |
'uglify', | |
'rev', | |
'usemin' | |
]); |
This file contains 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
<!-- change include file path to compiled file--> | |
<script src="scripts/compiled/services/services.js"></script> |
This file contains 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
//pom.xml configuration for integrate with java project (that's mean you can use java profile and build yo from `mvn`) | |
<plugin> | |
<groupId>com.github.trecloux</groupId> | |
<artifactId>yeoman-maven-plugin</artifactId> | |
<version>0.1</version> | |
<executions> | |
<execution> | |
<goals> | |
<goal>build</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment