add CDN host (perhaps not necessary?)

This commit is contained in:
Brandon Thomas committed 2016-11-06 05:55:06 -05:00
1 parent ccfbefddd1
commit a393a76920
4 files changed
+23 -7

No files matched your search

+5 -4
View File
@@ -6,18 +6,19 @@ import $ = require('jquery');
import { trumpAnimation } from './trump_animation';
import { getRandomInt } from './util';
/**
* The image path on AWS is stored under a content hash.
* This is injected into the meta tags before upload so we can build the path.
*/
function getImagePathPrefix() : string {
let environment = $('meta[name=environment]').attr('content'),
contentHash = $('meta[name=content_hash]').attr('content');
// TODO: Cache the values looked up from the DOM statically.
let environment = $('meta[name=environment]').attr('content');
switch (environment.toLowerCase()) {
case 'production':
return `/assets/${contentHash}/images`;
let cdnHost = $('meta[name=cdn_host]').attr('content'),
contentHash = $('meta[name=content_hash]').attr('content');
return `${cdnHost}/assets/${contentHash}/images`;
default:
return '/assets/images';
}
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*.jungle.horse</AllowedOrigin>
<AllowedOrigin>*.junglehorse.com</AllowedOrigin>
<AllowedOrigin>jungle.horse</AllowedOrigin>
<AllowedOrigin>junglehorse.com</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
+4 -3
View File
@@ -9,7 +9,7 @@ build_assets() {
}
echo "> Build artifact."
#build_assets
build_assets
# Calculate output directory.
echo "> Calculate artifact SHA."
@@ -40,12 +40,13 @@ sed -i "s/\/assets/\/\/cdn.junglehorse.com\/assets\/${checksum}/g" index.html
sed -i "s/asset_content_hash/${checksum}/g" index.html
sed -i "s/DEVELOPMENT/production/g" index.html
sed -i "s/API_HOST/http:\/\/jungle.horse/g" index.html
sed -i "s/CDN_HOST/\/\/cdn.junglehorse.com/g" index.html
popd > /dev/null
echo "> Upload to S3."
aws s3 cp $output_dir s3://junglehorse-frontend/assets/${checksum} --recursive
aws s3 cp $output_dir/index.html s3://junglehorse-frontend/index.html
aws s3 cp $output_dir/error.html s3://junglehorse-frontend/error.html
aws s3 cp $output_dir/index.html s3://junglehorse.com/index.html
aws s3 cp $output_dir/error.html s3://junglehorse.com/error.html
popd > /dev/null
echo "> Done."
+1
View File
@@ -11,6 +11,7 @@
<meta name="content_hash" content="asset_content_hash">
<meta name="environment" content="DEVELOPMENT">
<meta name="api_host" content="API_HOST">
<meta name="cdn_host" content="CDN_HOST">
</head>
<body>
<div id="animation"></div>