I am having a problem when it comes to directing a test link to staging
environment VS to production
environment.
Current behaviour: When I tried to run this command on my terminal ember deploy staging
and it created a test link successfully. However, my component has a line of code that checks which environment the app currently pointed to. Unfortunately, it pointed to production
environment
Expected behaviour: What I am trying to achieve is when I run the command ember deploy staging
it should point to staging
environment not production
environment
Question: How to tell ember that create a test linkfor a staging environment?
Please see my code below for ../config/deploy.js
/* jshint node: true */
module.exports = function(deployTarget) {
var ENV = {
build: {
environment: 'production'
},
};
ENV['revision-data'] = {
type: 'git-commit'
};
ENV['s3'] = {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_ACCESS_KEY_SECRET,
bucket: 'sample',
prefix: deployTarget + '/dist/www',
region: 'us-east-1',
filePattern: '**/*.{js,css,png,gif,ico,jpg,xml,txt,svg,swf,eot,ttf,woff,woff2}'
};
ENV['redis'] = {
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
password: process.env.REDIS_PASSWORD,
maxRecentUploads: 30
};
ENV['gzip'] = {
'filePattern': '**/*.{js,css,json,ico,xml,txt,svg,eot,ttf,woff,woff2}'
};
ENV['rollbar'] = {
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
accessServerToken: process.env.ROLLBAR_SERVER_ACCESS_TOKEN,
minifiedPrependUrl: 'https://cdn1-' + deployTarget + '.sample.com/dist/www/',
rollbarConfig: {
enabled: true,
environment: deployTarget,
captureUncaught: true
}
};
if (deployTarget === 'production') {
ENV.rollbar.minifiedPrependUrl = 'https://cdn1.sample.com/dist/www/';
}
return ENV;
};
this is the code of my component that checks which environment you are currently in once you created a test link /components/my-component/component.js
import Ember from 'ember';
import config from '../../../config/environment';
export default Ember.Component.extend({
isProduction: config.environment === 'production',
myEnvironment: config.environment;
});
And the myEnvironment
returns production
environment upon logging on my /component/my-component/template.hbs
This is the code of my .env.deploy.staging
CLIENT_HOST=https://staging.sample.com
ASSETS_PREFIX=https://cdn1-staging.sample.com/dist/www/
S3_ACCESS_KEY_ID=ABCDEF123456
S3_ACCESS_KEY_SECRET=ABCDEF123456
ROLLBAR_ACCESS_TOKEN=ABCDEF123456
ROLLBAR_SERVER_ACCESS_TOKEN=ABCDEF123456
Any response is much appreciated. Hoping someone could help me, thank you!
Aucun commentaire:
Enregistrer un commentaire