Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit ecf3fba

Browse files
committed
Adding hosting static files straight from S3
1 parent 6f9127f commit ecf3fba

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
public/bundle
22
src/bundles
33
dist
4+
dist_static
45
node_modules
56
lambda
67
testinglambda.js

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
LAMBDA_BUCKET_NAME: react-lambda-example/lambda_versions
77
STATIC_BUCKET_NAME: react-lambda-example/static_versions
88
AWS_REGION: us-east-1
9+
AWS_STATIC_DOMAIN: http://react-lambda-example.s3-website-us-east-1.amazonaws.com/static_versions/
910
test:
1011
override:
1112
-

src/components/HtmlDocument/HtmlDocument.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ class HtmlDocument extends React.Component {
3737
}
3838

3939
render() {
40+
const awsHost = (process.env.AWS_STATIC_DOMAIN || '');
41+
const buildNumber = (process.env.CIRCLE_BUILD_NUM || '');
42+
let domainUrl = '';
43+
44+
if(awsHost && buildNumber) {
45+
domainUrl = `${awsHost}/${buildNumber}/`;
46+
}
47+
48+
console.log('AWS HOST: ', awsHost);
49+
console.log('BUILD NUMBER: ', buildNumber);
50+
console.log('DOMAIN URL: ', buildNumber);
51+
4052
const { markup, script, css } = this.props;
4153

4254
return (
@@ -49,7 +61,7 @@ class HtmlDocument extends React.Component {
4961
<title>React-Lambda-Example</title>
5062

5163
{ /* Listing all css files from webpack. */ }
52-
{ css.map((href, k) => <link key={k} rel="stylesheet" href={href.substring(1)} />) }
64+
{ css.map((href, k) => <link key={k} rel="stylesheet" href={domainUrl + href} />) }
5365
</head>
5466

5567
<body>
@@ -60,7 +72,7 @@ class HtmlDocument extends React.Component {
6072
<script dangerouslySetInnerHTML={{ __html: 'window.app=' + JSON.stringify(this.props.dataRender) + ';' }} />
6173

6274
{ /* Adds all scripts from webpack. */ }
63-
{ script.map((src, k) => <script key={k} src={src.substring(1)} />) }
75+
{ script.map((src, k) => <script key={k} src={domainUrl + src} />) }
6476
</body>
6577
</html>
6678
);

0 commit comments

Comments
 (0)