Skip to content

Commit

Permalink
Added Env Config
Browse files Browse the repository at this point in the history
  • Loading branch information
prabinv committed Mar 13, 2014
1 parent 44adf5e commit 23fe173
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 7 deletions.
49 changes: 45 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ module.exports = function (grunt) {
watch: {
views: {
files: ['<%= yeoman.app %>/{,*/}*.html'],
tasks: ['htmlmin', 'browserify:test'],
tasks: ['htmlmin', 'browserify:test', 'karma'],
options: {
livereload: true
}
},
js: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all', 'copy:scripts', 'browserify:test'],
tasks: ['newer:jshint:all', 'replace:dev', 'copy:scripts', 'browserify:test', 'karma'],
options: {
livereload: true
}
Expand Down Expand Up @@ -387,6 +387,35 @@ module.exports = function (grunt) {
}
},

replace: {
dev: {
options: {
patterns: [{
json: grunt.file.readJSON('./config/env/dev.json')
}]
},
files: [{
expand: true,
flatten: true,
src: ['./config/config.js'],
dest: '.tmp/scripts/services/'
}]
},
prod: {
options: {
patterns: [{
json: grunt.file.readJSON('./config/env/prod.json')
}]
},
files: [{
expand: true,
flatten: true,
src: ['./config/config.js'],
dest: '.tmp/scripts/services/'
}]
}
},

// Test settings
karma: {
unit: {
Expand Down Expand Up @@ -419,6 +448,7 @@ module.exports = function (grunt) {

grunt.task.run([
'clean:server',
'replace:dev',
'bower-install',
'concurrent:server',
'autoprefixer',
Expand All @@ -438,6 +468,7 @@ module.exports = function (grunt) {

grunt.registerTask('test', [
'clean:server',
'replace:dev',
'concurrent:test',
'autoprefixer',
'copy:scripts',
Expand All @@ -447,8 +478,18 @@ module.exports = function (grunt) {
'karma'
]);

grunt.registerTask('build', [
grunt.registerTask('build:dev', [
'clean:dist',
'replace:dev',
'build'
]);

grunt.registerTask('build:prod', [
'replace:prod',
'build'
]);

grunt.registerTask('build', [
'bower-install',
'useminPrepare',
'concurrent:dist',
Expand All @@ -468,6 +509,6 @@ module.exports = function (grunt) {
grunt.registerTask('default', [
'newer:jshint',
'test',
'build'
'build:dev'
]);
};
8 changes: 5 additions & 3 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ angular.module('volusionApp', [
'ngSanitize',
'ui.router',
'seo',
'pascalprecht.translate'
'pascalprecht.translate',
require('./services/config').name
])
.provider('api', require('./services/api-provider'))
.config(function(
Expand All @@ -29,10 +30,11 @@ angular.module('volusionApp', [
$locationProvider,
$translateProvider,
$translatePartialLoaderProvider,
apiProvider) {
apiProvider,
config) {

$locationProvider.html5Mode(true);
apiProvider.setBaseRoute('http://www.v65.com/api/v1/');
apiProvider.setBaseRoute(config.API_URL);
$urlRouterProvider.otherwise(getI18NPath);

var i18NPrefix = '/:region/:language-:country';
Expand Down
9 changes: 9 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*global angular: true*/
/*jshint -W109 */
'use strict';
var angular = require('angular');

module.exports = angular.module('services.config', [])
.constant('config', {
ENV: @@config
});
5 changes: 5 additions & 0 deletions config/env/dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"config": {
"API_URL": "http://volusion.apiary.io"
}
}
5 changes: 5 additions & 0 deletions config/env/prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"config": {
"API_URL": "/api/v1"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"grunt-karma": "~0.6.2",
"grunt-newer": "~0.6.1",
"grunt-ngmin": "0.0.3",
"grunt-replace": "~0.7.2",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.3.1",
"grunt-usemin": "~2.0.2",
Expand Down

0 comments on commit 23fe173

Please sign in to comment.