diff --git a/.eslintrc b/.eslintrc index edf1cde..e2a8230 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,6 +13,8 @@ ], "rules": { "no-console": 1, - "prettier/prettier": 2 + "prettier/prettier": 2, + "@typescript-eslint/no-empty-interface": 1, + "@typescript-eslint/triple-slash-reference": 1 } } \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index edf1cde..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint", - "prettier" - ], - "extends": [ - "prettier", - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - "no-console": 1, - "prettier/prettier": 2 - } -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index a404ce9..6d3f122 100755 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ yarn-error.log* .webpack .webpackCache.serverless/ + +.serverless/ +.cache/.serverless/ +.serverless/ diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 8d10a7c..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,16 +0,0 @@ -pipeline { - agent { - docker { - image 'node:12' - } - - } - stages { - stage('error') { - steps { - sh 'yarn build' - } - } - - } -} \ No newline at end of file diff --git a/README.md b/README.md index a57731b..6242f12 100755 --- a/README.md +++ b/README.md @@ -1,47 +1,3 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). # Deploy the client bundle diff --git a/babel.config.js b/babel.config.js index 4f6c4bc..8ceeb03 100644 --- a/babel.config.js +++ b/babel.config.js @@ -20,52 +20,51 @@ const alias = pathsEntries.reduce( module.exports = api => { const { NODE_ENV, TARGET } = process.env; - const isProduction = NODE_ENV === "production"; - const isServer = TARGET === "server"; + const isProduction = NODE_ENV === 'production'; + const isServer = TARGET === 'server'; api.cache(() => `${NODE_ENV}${TARGET}`); // client settings in .browserslistrc - const targets = isServer ? { node: "current" } : undefined; + const targets = isServer ? { node: 'current' } : undefined; const presets = [ [ - "@babel/preset-env", + '@babel/env', { - targets, - loose: true, - modules: false, - useBuiltIns: "usage", - corejs: 3 - } + useBuiltIns: 'entry', + corejs: '3.6', + }, ], - "@babel/preset-typescript", - "@babel/preset-react" + '@babel/preset-typescript', + '@babel/preset-react', ]; const plugins = [ - ["@babel/plugin-proposal-class-properties", { loose: true }], ["babel-plugin-module-resolver", { alias }], - ["@babel/plugin-transform-runtime"], - ["@babel/plugin-proposal-do-expressions"], - ["@babel/plugin-proposal-export-default-from"], - ["@babel/plugin-proposal-export-namespace-from"], - ["@babel/plugin-proposal-optional-chaining"], - ["@babel/plugin-proposal-partial-application"], - ["@babel/plugin-proposal-throw-expressions"], - ["@babel/plugin-proposal-nullish-coalescing-operator"], - [ - "@babel/plugin-proposal-pipeline-operator", - { proposal: "minimal" } - ] + ['@babel/plugin-proposal-object-rest-spread'], + ['@babel/plugin-syntax-dynamic-import'], + ['babel-plugin-root-import'], + ['@babel/plugin-proposal-class-properties', { loose: true }], + ['@babel/plugin-transform-runtime'], + ['@babel/plugin-proposal-do-expressions'], + ['@babel/plugin-proposal-export-default-from'], + ['@babel/plugin-proposal-export-namespace-from'], + ['@babel/plugin-proposal-optional-chaining'], + ['@babel/plugin-proposal-partial-application'], + ['@babel/plugin-proposal-throw-expressions'], + ['@babel/plugin-proposal-nullish-coalescing-operator'], + ['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }], ]; if (isProduction) { - plugins.push(["@babel/plugin-transform-react-inline-elements"]); + plugins.push(['@babel/plugin-transform-react-inline-elements']); } return { + ignore: ['*.scss', '/node_modules/'], presets, - plugins + plugins, + "sourceType": "unambiguous" }; }; diff --git a/cleanse.sh b/cleanse.sh new file mode 100644 index 0000000..95e020e --- /dev/null +++ b/cleanse.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +git filter-branch --tree-filter "rm -rf webpack/.cache" --prune-empty HEAD +git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d +echo .serverless/ >> .gitignore +git add .gitignore +git commit -m 'Removing .serverless from git history' +git gc diff --git a/package-lock.json b/package-lock.json index de0f828..95bbace 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "fandanzle-v2", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 17b5e53..7d75ff1 100644 --- a/package.json +++ b/package.json @@ -1,51 +1,126 @@ { "name": "fandanzle-v2", - "version": "1.0.0", + "version": "1.0.1", "private": true, "scripts": { "cleanup": "rimraf dist/", "test": "jest", "prestart": "rimraf dist", "prebuild": "rimraf dist", - "devserver": "cross-env NODE_ENV=development TARGET=client webpack serve --config webpack.config.js --mode development --inline --hot", - "prodserver": "cross-env NODE_ENV=production TARGET=client webpack serve --config webpack.config.js --mode production", - "dev": "NODE_ENV=development IS_LOCAL=TRUE NODE_CONFIG_ENV=development-local yarn cleanup && yarn build:style-typings && concurrently -r --kill-others \"yarn devserver\" \"webpack --config ./webpack/serverless/index.js --watch\" \"sls offline start --noPrependStageInUrl --stage=local-development\"", - "prod": "NODE_ENV=production IS_LOCAL=TRUE NODE_CONFIG_ENV=production-local yarn cleanup && yarn build:style-typings && concurrently -r --kill-others \"yarn build:prod\" \"yarn prodserver\" \"webpack --config ./webpack/serverless/index.js --watch\" \"sls offline start --noPrependStageInUrl --stage=local-production\"", - "build:client:dev": "yarn cleanup && cross-env NODE_ENV=development TARGET=client webpack", - "build:client:prod": "yarn cleanup && cross-env NODE_ENV=production TARGET=client webpack", - "build:dev": "yarn cleanup && cross-env NODE_ENV=development yarn build:client:dev && TARGET=serverless webpack", - "build:prod": "yarn cleanup && cross-env NODE_ENV=production yarn build:client:prod && TARGET=serverless webpack", + "start": "sls offline start", + "devserver": "NODE_ENV=development TARGET=client webpack serve --mode development --inline --hot", + "prodserver": "NODE_ENV=production TARGET=client webpack serve --mode production", + "build:client": "TARGET=client webpack", + "build:server": "TARGET=serverless webpack", + "build:server:prod": "NODE_ENV=production TARGET=serverless webpack", + "build": "yarn build:client && yarn build:server", + "build:dev": "yarn cleanup && NODE_ENV=development yarn build:client && yarn build:server", + "build:prod": "yarn cleanup && NODE_ENV=production yarn build:client && NODE_ENV=production yarn build:server", + "dev": "yarn cleanup && yarn types && yarn build:dev && NODE_ENV=development NODE_CONFIG_ENV=development-local concurrently -r \"yarn devserver\" \"sls offline start --noPrependStageInUrl\"", + "prod": "yarn cleanup && yarn types && yarn build:prod && NODE_ENV=production NODE_CONFIG_ENV=development-local concurrently -r \"yarn prodserver\" \"sls offline start --noPrependStageInUrl\"", "deploy:dev": "yarn build:dev && serverless deploy -v --stage development", - "deploy:staging": "yarn build:prod && serverless deploy -v --stage staging", "deploy:prod": "yarn build:prod && serverless deploy -v --stage production", "test:types": "tsc --noEmit", "hook:before:offline:start": "yarn build:client:prod", "build:style-typings": "node webpack/style-typings.js", "lint": "eslint ./src --ext .js --ext .ts --ext .tsx", "lint:fix": "eslint ./src --ext .js --ext .ts --ext .tsx --fix", - "types": "graphql-codegen --config codegen.yml" + "types": "tcm src" }, "devDependencies": { - "@babel/cli": "^7.0.0", - "@babel/core": "^7.4.5", - "@babel/plugin-proposal-class-properties": "^7.4.4", - "@babel/plugin-proposal-do-expressions": "^7.8.3", - "@babel/plugin-proposal-export-default-from": "^7.8.3", - "@babel/plugin-proposal-export-namespace-from": "^7.8.3", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-proposal-numeric-separator": "^7.8.3", - "@babel/plugin-proposal-object-rest-spread": "^7.0.0", - "@babel/plugin-proposal-optional-chaining": "^7.8.3", - "@babel/plugin-proposal-partial-application": "^7.8.3", - "@babel/plugin-proposal-pipeline-operator": "^7.8.3", - "@babel/plugin-proposal-throw-expressions": "^7.10.4", - "@babel/plugin-transform-react-inline-elements": "^7.2.0", - "@babel/plugin-transform-regenerator": "^7.4.5", - "@babel/plugin-transform-runtime": "^7.4.4", - "@babel/preset-env": "^7.4.5", - "@babel/preset-react": "^7.0.0", - "@babel/preset-typescript": "^7.3.3", - "@babel/register": "^7.0.0", + "webpack-hot-middleware": "^2.25.0", + "webpack-dev-middleware": "^4.0.2", + "css-minimizer-webpack-plugin": "^1.1.5", + "webpack-dev-server": "^3.11.1", + "workbox-webpack-plugin": "^6.0.2", + "optimize-css-assets-webpack-plugin": "^5.0.4", + "@babel/preset-typescript": "^7.12.7", + "babel-plugin-graphql-tag": "^2.5.0", + "process": "0.11.10", + "typescript": "^4.1.0", + "@babel/cli": "^7.12.1", + "@babel/core": "^7.12.1", + "@babel/plugin-transform-runtime": "^7.12.1", + "@babel/plugin-proposal-do-expressions": "^7.12.1", + "@babel/plugin-proposal-class-properties": "^7.12.1", + "@babel/plugin-proposal-function-bind": "^7.12.1", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1", + "@babel/plugin-proposal-object-rest-spread": "^7.12.1", + "@babel/plugin-proposal-optional-chaining": "^7.12.1", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-transform-regenerator": "^7.12.1", + "@babel/plugin-proposal-export-default-from": "^7.12.1", + "@babel/plugin-proposal-partial-application": "^7.12.1", + "@babel/plugin-proposal-throw-expressions": "^7.12.1", + "@babel/plugin-proposal-pipeline-operator": "^7.12.1", + "@babel/plugin-transform-react-inline-elements": "^7.12.1", + "@babel/preset-env": "^7.12.1", + "@babel/preset-react": "^7.12.1", + "@babel/register": "^7.12.1", + "@babel/runtime": "^7.12.1", + "assets-webpack-plugin": "^7.0.0", + "copy-webpack-plugin": "^7.0.0", + "webpack": "^5.11.0", + "image-webpack-loader": "^7.0.0", + "terser-webpack-plugin": "^5.0.3", + "webpack-bundle-analyzer": "^3.3.2", + "webpack-cli": "^4.3.1", + "webpack-merge": "^4.2.1", + "webpackbar": "^4.0.0", + "duplicate-package-checker-webpack-plugin": "^3.0.0", + "autoprefixer": "^7.1.6", + "babel-eslint": "^10.0.0", + "babel-jest": "^24.0.0", + "babel-loader": "^8.0.0", + "babel-plugin-istanbul": "^4.1.6", + "babel-plugin-module-resolver": "^3.2.0", + "cross-env": "^4.0.0", + "enzyme": "^3.10.0", + "enzyme-adapter-react-16": "^1.14.0", + "enzyme-to-json": "^3.4.0", + "eslint": "^7.8.10", + "eslint-config-prettier": "^7.1.0", + "eslint-import-resolver-webpack": "^0.12.0", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-jest": "^23.0.0", + "eslint-plugin-jsx-a11y": "^6.2.0", + "eslint-plugin-prettier": "^3.3.0", + "eslint-plugin-react": "^7.22.0", + "eslint-plugin-react-hooks": "^2.3.0", + "file-loader": "^3.0.1", + "husky": "^3.0.0", + "identity-obj-proxy": "^3.0.0", + "ignore-styles": "^5.0.1", + "isomorphic-style-loader": "v3.0.0", + "istanbul": "^0.4.5", + "istanbul-reports": "^1.3.0", + "jest": "^24.0.0", + "jest-each": "^24.0.0", + "jsdom": "^11.11.0", + "lerna": "^3.4.0", + "lint-staged": "^8.1.5", + "madge": "^3.4.4", + "prettier": "^1.18.2", + "react-test-renderer": "^16.4.1", + "redux-devtools-extension": "^2.13.0", + "rimraf": "^2.6.2", + "stylelint": "^10.1.0", + "stylelint-config-prettier": "^5.2.0", + "stylelint-config-standard": "^18.3.0", + "stylelint-prettier": "^1.1.1", + "stylelint-scss": "^3.9.0", + "whybundled": "^1.4.2", + "css-loader": "^5.0.1", + "style-loader": "^2.0.0", + "url-loader": "^4.1.1", + "mini-css-extract-plugin": "^1.3.3", + "postcss-loader": "^4.1.0", + "buffer": "^6.0.0", + "webpack-manifest-plugin": "^3.0.0", + "circular-dependency-plugin": "^5.2.2", + "react-hot-loader": "^4.13.0", + "resolve-url-loader": "^3.1.2", + "babel-plugin-root-import": "^6.6.0", "@commitlint/cli": "^8.0.0", "@commitlint/config-conventional": "^8.0.0", "@hot-loader/react-dom": "^16.12.0", @@ -81,37 +156,13 @@ "@typescript-eslint/eslint-plugin": "^3.10.1", "@typescript-eslint/parser": "^3.10.1", "aws-sdk": "^2.824.0", - "babel-loader": "^8.0.6", - "babel-plugin-module-resolver": "^3.2.0", - "circular-dependency-plugin": "^5.0.2", - "cross-env": "^5.2.0", - "css-loader": "^3.0.0", "cz-customizable": "^6.2.0", - "eslint": "^7.7.0", - "file-loader": "^4.0.0", "fork-ts-checker-webpack-plugin": "^1.3.5", - "glob": "^7.1.4", - "husky": "^2.4.0", - "identity-obj-proxy": "^3.0.0", - "isomorphic-style-loader": "^5.1.0", - "jest": "^24.8.0", - "lint-staged": "^8.2.0", - "mini-css-extract-plugin": "^0.7.0", - "node-sass": "^4.12.0", - "nodemon": "^1.19.1", - "npm-run-all": "^4.1.5", - "optimize-css-assets-webpack-plugin": "^5.0.1", - "parallel-webpack": "^2.6.0", "postcss-custom-media": "^7.0.8", "postcss-flexbugs-fixes": "^4.1.0", - "postcss-loader": "^3.0.0", "postcss-media-variables": "^2.0.1", "postcss-preset-env": "^6.6.0", - "prettier": "^2.1.1", - "redux-devtools-extension": "2.13.8", "redux-mock-store": "^1.5.3", - "resolve-url-loader": "^3.1.0", - "sass-loader": "^7.1.0", "serverless": "^1.60.1", "serverless-deployment-bucket": "^1.3.0", "serverless-domain-manager": "^3.3.0", @@ -132,45 +183,31 @@ "serverless-s3-sync": "^1.15.0", "serverless-webpack": "^5.3.2", "source-map-explorer": "^2.0.0", - "style-loader": "^0.23.1", - "terser-webpack-plugin": "^1.3.0", "ts-jest": "^24.0.2", "tslint": "^5.17.0", "tslint-react": "^4.0.0", - "typescript": "^3.5.1", - "webpack": "^4.44.2", - "webpack-cli": "^4.2.0", - "webpack-dev-middleware": "^4.0.2", - "webpack-dev-server": "^3.11.0", - "webpack-hot-middleware": "^2.25.0", - "webpack-manifest-plugin": "^2.0.4", - "webpack-merge": "^4.2.2", "webpack-node-externals": "^1.7.2", - "webpackbar": "^3.2.0", - "workbox-webpack-plugin": "^4.3.1" + "@types/redis": "^2.8.28", + "concurrently": "^4.1.0", + "extend": "^3.0.1", + "http-server": "^0.12.3", + "mockdate": "^2.0.2", + "picturefill": "^3.0.2", + "typed-css-modules": "^0.6.5", + "eslint-config-airbnb": "^18.2.0" }, "dependencies": { + "core-js": "^3.8.2", + "regenerator-runtime": "^0.13.3", "@babel/runtime": "^7.12.5", "aws-serverless-express": "^3.4.0", - "babel-polyfill": "^6.26.0", - "before-build-webpack": "^0.2.9", "classnames": "^2.2.6", "concurrently": "^5.3.0", "connected-react-router": "^6.7.0", - "core-js": "^3.6.4", - "enzyme": "^3.11.0", - "enzyme-adapter-react-16": "^1.15.3", - "eslint-config-airbnb": "^18.2.0", - "eslint-config-prettier": "^6.11.0", - "eslint-plugin-prettier": "^3.1.4", "express": "^4.16.4", "file-loader": "2.0.0", "fs-extra": "7.0.0", - "husky": "^2.2.0", - "isomorphic-fetch": "^2.2.1", "moment": "^2.24.0", - "nodemon": "^1.18.10", - "nodemon-webpack-plugin": "^4.3.1", "ramda": "^0.26.1", "react": "^16.13.0", "react-addons-css-transition-group": "^15.6.2", @@ -188,8 +225,6 @@ "redux-saga-requests-graphql": "^0.2.0", "reselect": "^4.0.0", "resolve": "^1.17.0", - "resolve-url-loader": "^3.1.1", - "typed-css-modules": "^0.6.3", "typesafe-actions": "^5.1.0" }, "browserslist": [ diff --git a/serverless-vars.js b/serverless-vars.js new file mode 100644 index 0000000..5472fb9 --- /dev/null +++ b/serverless-vars.js @@ -0,0 +1,10 @@ +const crypto = require('crypto'); + +const { BRANCH_NAME = 'development' } = process.env; + +const branchName = () => BRANCH_NAME.replace(/[^0-9a-z]/gi, '-'); + +exports.branchHash = () => + crypto.createHash('md5').update(branchName()).digest('hex').slice(0, 12); + +exports.branchName = branchName; diff --git a/serverless.yml b/serverless.yml index 37199cf..1205cb1 100644 --- a/serverless.yml +++ b/serverless.yml @@ -16,7 +16,7 @@ custom: stackName: ${self:service}-${self:provid ## - localDevStaticFolder: dist + localDevStaticFolder: build ## siteName: devnotnull.com @@ -34,9 +34,12 @@ custom: ## S3 bucket for static assets s3Sync: - - bucketName: fandanzle-assets-${self:provider.stage} + - bucketName: fandanzle-assets-${self:custom.environment} bucketPrefix: static/ - localDir: dist/static + localDir: build/static + + ## + environment: ${opt:stage, 'development'} ## package: @@ -51,12 +54,15 @@ provider: runtime: nodejs12.x timeout: 10 region: ${opt:region, 'eu-west-2'} + stackName: ${self:service}-${self:custom.environment} environment: - NODE_ENV: ${self:provider.stage} + NODE_RUNTIME_ENV: ${self:custom.environment} functions: server: - handler: dist/serverless.handler + handler: build/serverless.handler + environment: + NODE_RUNTIME_ENV: ${self:custom.environment} events: - http: method: GET @@ -67,7 +73,7 @@ resources: AssetsBucket: Type: AWS::S3::Bucket Properties: - BucketName: fandanzle-assets-${self:provider.stage} + BucketName: fandanzle-assets-${self:custom.environment} BucketPolicy: Type: AWS::S3::BucketPolicy Properties: diff --git a/src/client/index.tsx b/src/client/index.tsx index 99e56fd..bde5dc8 100755 --- a/src/client/index.tsx +++ b/src/client/index.tsx @@ -1,11 +1,11 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { Provider } from 'react-redux' -import { BrowserRouter } from "react-router-dom"; +import { Provider } from 'react-redux'; +import { BrowserRouter } from 'react-router-dom'; import createHistory from 'history/createBrowserHistory'; import rootSaga from '../core/sagas'; -import createStore from '../core/store' +import createStore from '../core/store'; import App from '../web/app'; // Grab the state from a global variable injected into the server-generated HTML @@ -20,27 +20,12 @@ const store = createStore(history, preloadedState); const renderApp = () => { ReactDOM.render( - + , document.getElementById('root') ); -} +}; -// renderApp(); - -// Server side rendering -if ((module as any).hot) { - // - (module as any).hot.accept('../web/app', () => { - // const newApp = require('../web/app').default; - renderApp(); - }); - // - (module as any).hot.accept('../core/sagas', () => { - (store as any).closeSagas(); - (store as any).rootTask = (store as any).runSaga(require('../core/sagas').default); - }); -} \ No newline at end of file diff --git a/src/core/portfolio/reducer.ts b/src/core/portfolio/reducer.ts index 0d030ab..48f6e02 100644 --- a/src/core/portfolio/reducer.ts +++ b/src/core/portfolio/reducer.ts @@ -30,7 +30,6 @@ export const portfolio: Reducer = ( return { ...state, loading: true, errors: undefined }; } case FolioActionTypes.FETCH_SUCCESS: { - console.log(JSON.stringify(action.payload)); return { ...state, loading: false, diff --git a/src/core/store.ts b/src/core/store.ts index 0486036..248b5b1 100644 --- a/src/core/store.ts +++ b/src/core/store.ts @@ -10,13 +10,8 @@ import { composeWithDevTools } from 'redux-devtools-extension'; import { routerMiddleware } from 'connected-react-router'; import rootReducers from '../core/reducers'; -import { isServerRender } from '../utils'; export default (history: any, reduxState = undefined) => { - // - console.log('Is this a server side render'); - console.log(isServerRender); - // Compose our middlewares const saga: SagaMiddleware = createSaga(); const router: Middleware = routerMiddleware(history); diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 69de45b..9e22f95 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -4,7 +4,7 @@ declare namespace NodeJS { interface ProcessEnv { - NODE_ENV: 'development' | 'production' | 'test'; + NODE_ENV: string; PUBLIC_URL: string; } } @@ -47,7 +47,7 @@ declare module '*.webp' { declare module '*.svg' { import * as React from 'react'; - export const ReactComponent: React.SFC>; + export const ReactComponent: React.FC>; const src: string; export default src; diff --git a/src/server/config.ts b/src/server/config.ts index c8f5018..69099e2 100644 --- a/src/server/config.ts +++ b/src/server/config.ts @@ -1,54 +1,44 @@ -import { merge } from "ramda"; +import { merge } from 'ramda'; export interface AppConfig { - static: { - path: string; - }; + static: { + path: string; + }; } export type Environment = - | "common" - | "developmentLocal" - | "development" - | "stagingLocal" - | "staging" - | "productionLocal" - | "production"; + | 'common' + | 'developmentLocal' + | 'development' + | 'productionLocal' + | 'production'; type Config = { [key in Environment]: Partial; }; -const env = process.env.NODE_RUNTIME_ENV || "development"; +const env = process.env.NODE_RUNTIME_ENV || 'development'; const offline = process.env.IS_OFFLINE || false; const defaultConfig: Config = { common: { static: { - path: - "http://localhost:9000/", - }, + path: 'http://localhost:9000/' + } }, development: { static: { - path: - "https://ecom-rc-backoffice-ui-development-assets.s3.eu-west-1.amazonaws.com/", - }, + path: 'https://fandanzle-assets-development.s3.eu-west-2.amazonaws.com' + } }, developmentLocal: {}, - stagingLocal: {}, - staging: { - static: { - path: - "https://ecom-rc-backoffice-ui-development-assets.s3.eu-west-1.amazonaws.com/", - }, - }, productionLocal: {}, + productionLocal: {}, production: { static: { - path: - "https://ecom-rc-backoffice-ui-development-assets.s3.eu-west-1.amazonaws.com/", - }, - },}; + path: 'https://fandanzle-assets-production.s3.eu-west-2.amazonaws.com' + } + } +}; const envKey = offline ? `${env}Local` : env; diff --git a/src/server/handler.ts b/src/server/handler.ts index 55ab3ae..3654295 100644 --- a/src/server/handler.ts +++ b/src/server/handler.ts @@ -1,10 +1,9 @@ -import { APIGatewayEvent, Context } from "aws-lambda"; -import { createServer, proxy } from "aws-serverless-express"; -import "regenerator-runtime/runtime"; +import { APIGatewayEvent, Context } from 'aws-lambda'; +import { createServer, proxy } from 'aws-serverless-express'; +import 'regenerator-runtime/runtime'; +import 'source-map-support/register'; -import { app } from "./http"; - -require("source-map-support").install(); +import { app } from './http'; const server = createServer(app); diff --git a/src/server/html.tsx b/src/server/html.tsx index 7c73606..718b0cd 100644 --- a/src/server/html.tsx +++ b/src/server/html.tsx @@ -1,6 +1,6 @@ -import React, { FC, ReactElement } from "react"; -import { renderToString } from "react-dom/server"; -import Helmet from "react-helmet"; +import React, { FC, ReactElement } from 'react'; +import { renderToString } from 'react-dom/server'; +import Helmet from 'react-helmet'; /** * @@ -23,7 +23,7 @@ const Html: FC = ({ rootComponent, buildProd, config, - splitPoints, + splitPoints }) => { // Asset var is hydrate at runtime // Please note is is not set when running dev @@ -35,14 +35,14 @@ const Html: FC = ({ const keys = Object.keys(assets); const js = keys.filter( - (a) => a.includes(".js") && !a.includes(".map") && !a.includes(".json") + a => a.includes('.js') && !a.includes('.map') && !a.includes('.json') ); - const css = keys.filter((a) => a.includes(".css") && !a.includes(".map")); + const css = keys.filter(a => a.includes('.css') && !a.includes('.map')); - let srcJsFiles = js.map((key) => ( + let srcJsFiles = js.map(key => (