This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b3e3db
commit 741ebc5
Showing
46 changed files
with
10,972 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"plugins": [ | ||
["module-resolver", { | ||
"extensions": [ ".ts", ".tsx" ], | ||
"root": [ "./src" ] | ||
}], | ||
["styled-components", { | ||
"displayName": false, | ||
"preprocess": false, | ||
"ssr": true | ||
}] | ||
], | ||
"env": { | ||
"development": { | ||
"presets": [ | ||
["@babel/env", { | ||
"targets": { "browsers": [] } | ||
}], | ||
["@babel/stage-0", { "decoratorsLegacy": true }], | ||
"@babel/react", | ||
"@babel/typescript" | ||
] | ||
}, | ||
"production": { | ||
"presets": [ | ||
["@babel/env", { | ||
"targets": { "browsers": [ "last 2 versions" ] } | ||
}], | ||
["@babel/stage-0", { "decoratorsLegacy": true }], | ||
"@babel/react", | ||
"@babel/typescript" | ||
] | ||
}, | ||
"serverless": { | ||
"presets": [ | ||
[ "@babel/env", { | ||
"targets": { "node": "6.10" } | ||
}], | ||
["@babel/stage-0", { "decoratorsLegacy": true }], | ||
"@babel/react", | ||
"@babel/typescript" | ||
] | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
S3_DEPLOYMENT_BUCKET=com.example.artifacts | ||
|
||
API_DOMAIN_NAME=api.example.com | ||
APP_DOMAIN_NAME=example.com | ||
APP_HOSTED_ZONE=example.com |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
sudo: required | ||
language: bash | ||
services: | ||
- docker | ||
|
||
env: | ||
global: | ||
- CONTAINER_NAME=serverless-react/travis | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
cache: | ||
directories: | ||
- $TRAVIS_BUILD_DIR/node_modules | ||
|
||
before_install: | ||
- docker build -t $CONTAINER_NAME | ||
|
||
install: | ||
- docker run --rm --tty --volume $TRAVIS_BUILD_DIR:/var/task --workdir /var/task $CONTAINER_NAME yarn | ||
|
||
script: | ||
- docker run --rm --tty --volume $TRAVIS_BUILD_DIR:/var/task --workdir /var/task $CONTAINER_NAME yarn run tsc | ||
- docker run --rm --tty --volume $TRAVIS_BUILD_DIR:/var/task --workdir /var/task $CONTAINER_NAME yarn run tslint | ||
- docker run --rm --tty --volume $TRAVIS_BUILD_DIR:/var/task --workdir /var/task $CONTAINER_NAME yarn run build:static | ||
- docker run --rm --tty --volume $TRAVIS_BUILD_DIR:/var/task --workdir /var/task $CONTAINER_NAME yarn run build:server |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:latest@sha256:492f2a28fbc54cf96eb0eea3faa2486179c71b3154a6b3e6b89b6c36ef7f59eb | ||
|
||
# install the latest version of yarn | ||
RUN curl -o- -L https://yarnpkg.com/install.sh | bash | ||
ENV PATH /root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:$PATH | ||
|
||
# check versions | ||
RUN yarn --version | ||
|
||
# expose development ports | ||
EXPOSE 3000:3000 | ||
EXPOSE 3001:3001 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Load the environment variables | ||
ifdef ENV | ||
export ENV_FILE = .env.$(ENV) | ||
else | ||
export ENV_FILE = .env | ||
endif | ||
|
||
# Include the envionment variables in this Makefile | ||
include $(ENV_FILE) | ||
|
||
# Export these variables for docker-compose usage | ||
export CONTAINER_NAME = serverless-react/devbox | ||
export NODE_CONTAINER = \ | ||
--interactive \ | ||
--rm \ | ||
--tty \ | ||
--volume $(shell pwd):/var/task \ | ||
--workdir /var/task \ | ||
$(CONTAINER_NAME) | ||
|
||
build: | ||
@docker run --env-file $(ENV_FILE) $(NODE_CONTAINER) yarn run build | ||
|
||
deploy: | ||
@make stop-docker | ||
@docker run --env-file $(ENV_FILE) $(NODE_CONTAINER) yarn run deploy:$(ENV) | ||
|
||
check: | ||
@make tsc | ||
@make tslint | ||
|
||
dev: | ||
@docker run --env-file $(ENV_FILE) $(NODE_CONTAINER) /bin/bash | ||
|
||
devbox: | ||
@docker build --no-cache --tag $(CONTAINER_NAME) . | ||
|
||
install: | ||
@docker run $(NODE_CONTAINER) yarn install | ||
|
||
profile: | ||
@docker run --env-file $(ENV_FILE) $(NODE_CONTAINER) yarn run profile | ||
|
||
start: | ||
@docker-compose -f docker-compose.yml down --remove-orphans --volumes | ||
@docker-compose -f docker-compose.yml up -d --no-recreate --remove-orphans | ||
|
||
start-hard: | ||
rm -rf node_modules | ||
rm -f yarn.lock | ||
make devbox | ||
make install | ||
make start | ||
|
||
stop: | ||
@docker-compose -f docker-compose.yml down --remove-orphans --volumes | ||
|
||
stop-docker: | ||
@docker ps -aq | xargs docker stop | ||
@docker ps -aq | xargs docker rm | ||
|
||
tsc: | ||
@docker run --env-file $(ENV_FILE) $(NODE_CONTAINER) yarn run tsc | ||
|
||
tslint: | ||
@docker run --env-file $(ENV_FILE) $(NODE_CONTAINER) yarn run tslint | ||
|
||
tslint-fix: | ||
@docker run --env-file $(ENV_FILE) $(NODE_CONTAINER) yarn run tslint:fix |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const CircularDependencyPlugin = require('circular-dependency-plugin') | ||
const path = require('path') | ||
const slsw = require('serverless-webpack') | ||
const webpack = require('webpack') | ||
const nodeExternals = require('webpack-node-externals') | ||
|
||
const config = { | ||
mode: slsw.lib.webpack.isLocal ? 'development' : 'production', | ||
target: 'node', | ||
entry: slsw.lib.entries, | ||
externals: [nodeExternals()], | ||
output: { | ||
filename: '[name].js', | ||
libraryTarget: 'commonjs', | ||
path: path.resolve(process.cwd(), '.webpack'), | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
enforce: 'pre', | ||
exclude: /node_modules/, | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ loader: require.resolve('tslint-loader') } | ||
] | ||
}, | ||
{ | ||
exclude: /node_modules/, | ||
test: /\.(graphql|gql)$/, | ||
use: [ | ||
{ loader: require.resolve('graphql-tag/loader') } | ||
] | ||
}, | ||
{ | ||
exclude: /node_modules/, | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ loader: require.resolve('babel-loader') }, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.NoEmitOnErrorsPlugin(), | ||
new CircularDependencyPlugin({ | ||
exclude: /node_modules/, | ||
failOnError: process.env.NODE_ENV === 'production' | ||
}), | ||
], | ||
resolve: { | ||
extensions: [ | ||
'.gql', | ||
'.graphql', | ||
'.json', | ||
'.ts', | ||
'.tsx', | ||
], | ||
modules: [ | ||
path.resolve(process.cwd(), 'node_modules'), 'node_modules', | ||
'src/app' | ||
], | ||
}, | ||
} | ||
|
||
// patch serverless-offline, lambda always returns :UTC for the TZ and is a reserved variable | ||
if (slsw.lib.webpack.isLocal) { | ||
config.plugins.push(new webpack.DefinePlugin({ 'process.env.TZ': JSON.stringify(':UTC') })) | ||
} | ||
|
||
module.exports = config |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const CircularDependencyPlugin = require('circular-dependency-plugin') | ||
const path = require('path') | ||
const slsw = require('serverless-webpack') | ||
const webpack = require('webpack') | ||
|
||
module.exports = { | ||
mode: process.env.NODE_ENV || 'development', | ||
devtool: 'eval-source-map', | ||
target: 'web', | ||
entry: { | ||
main: [ | ||
path.resolve(process.cwd(), 'src/platforms/browser/main.ts') | ||
], | ||
}, | ||
externals: [], | ||
optimization: { | ||
// https://webpack.js.org/plugins/split-chunks-plugin/#split-chunks-example-2 | ||
splitChunks: { | ||
cacheGroups: { | ||
commons: { | ||
chunks: 'all', | ||
name: 'vendors', | ||
test: /[\\/]node_modules[\\/]/ | ||
} | ||
} | ||
} | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
path: path.resolve(process.cwd(), 'dist'), | ||
publicPath: '/static/' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
enforce: 'pre', | ||
exclude: /node_modules/, | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ loader: require.resolve('tslint-loader') } | ||
] | ||
}, | ||
{ | ||
exclude: /node_modules/, | ||
test: /\.(graphql|gql)$/, | ||
use: [ | ||
{ loader: require.resolve('graphql-tag/loader') } | ||
] | ||
}, | ||
{ | ||
exclude: /node_modules/, | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ loader: require.resolve('babel-loader') }, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin(Object.assign({}, Object.keys(process.env).reduce((obj, key) => ( | ||
Object.assign(obj, { [`process.env.${key}`]: JSON.stringify(process.env[key]) }) | ||
), {}), { | ||
'process.env.PACKAGE_VERSION': '0.1.0' // JSON.stringify(package.version), | ||
})), | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.NoEmitOnErrorsPlugin(), | ||
new CircularDependencyPlugin({ exclude: /node_modules/, failOnError: true }), | ||
], | ||
resolve: { | ||
extensions: [ | ||
'.gql', | ||
'.graphql', | ||
'.js', | ||
'.json', | ||
'.ts', | ||
'.tsx', | ||
], | ||
modules: [ | ||
path.resolve(process.cwd(), 'node_modules'), 'node_modules', | ||
'src/app' | ||
], | ||
}, | ||
devServer: { | ||
host: process.env.HOST || '0.0.0.0', | ||
port: 3000, | ||
proxy: { | ||
// This proxies the docker website.server service when running `make start-website` | ||
'/': 'http://website.server:3001' | ||
}, | ||
publicPath: '/static/' | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: '3' | ||
services: | ||
website.server: | ||
container_name: serverless-react.website.server | ||
command: yarn run start:server | ||
env_file: | ||
- ${ENV_FILE} | ||
image: ${CONTAINER_NAME} | ||
ports: | ||
- 3001:3001 | ||
restart: always | ||
volumes: | ||
- .:/var/task | ||
working_dir: /var/task | ||
|
||
website.static: | ||
container_name: serverless-react.website.static | ||
command: yarn run start:static | ||
env_file: | ||
- ${ENV_FILE} | ||
image: ${CONTAINER_NAME} | ||
ports: | ||
- 3000:3000 | ||
restart: always | ||
volumes: | ||
- .:/var/task | ||
working_dir: /var/task |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as website } from './src/platforms/lambda/server' |
Oops, something went wrong.