Created
May 26, 2018 20:35
-
-
Save babie/1052159a6d5edf8df51d297210925a31 to your computer and use it in GitHub Desktop.
Transform aws-sam & create-react-app codes from JavaScript to TypeScript
This file contains hidden or 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
const fs = require('fs') | |
const path = require('path') | |
const appDirectory = fs.realpathSync(process.cwd()) | |
const resolveApp = relativePath => path.resolve(appDirectory, relativePath) | |
module.exports = { | |
webpack: (config, env) => ({ | |
...config, | |
entry: [resolveApp('src/server.ts')], | |
target: 'node', | |
output: { | |
...config.output, | |
filename: 'index.js', | |
libraryTarget: 'commonjs' | |
} | |
}) | |
} |
This file contains hidden or 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
{ | |
"name": "example", | |
"version": "0.1.0", | |
"private": true, | |
"homepage": "https://example.com", | |
"proxy": "http://localhost:3001", | |
"dependencies": { | |
"aws-serverless-express": "^3.2.0", | |
"express": "^4.16.3", | |
"react": "^16.3.2", | |
"react-dom": "^16.3.2", | |
"react-scripts-ts": "2.16.0" | |
}, | |
"scripts": { | |
"start": "run-p start:aws start:cra", | |
"start:aws": "sam local start-api -p 3001 --static-dir server", | |
"start:cra": "react-scripts-ts start", | |
"build": "run-s clear build:aws move:aws build:cra move:cra", | |
"build:aws": "react-app-rewired build --scripts-version react-scripts-ts", | |
"build:cra": "react-scripts-ts build", | |
"clear": "run-p clear:aws clear:cra", | |
"clear:aws": "rm -rf server", | |
"clear:cra": "rm -rf client", | |
"move:aws": | |
"mv -f build server && find ./server -type f -not -name 'index.js*' -exec rm {} \\;", | |
"move:cra": "mv -f build client", | |
"test": "run-p test:aws test:cra", | |
"test:aws": | |
"react-app-rewired test --scripts-version react-scripts-ts --env=jsdom", | |
"test:cra": "react-scripts-ts test --env=jsdom", | |
"lint": "tslint --project tsconfig.json", | |
"format": "tslint --project tsconfig.json --fix", | |
"eject": "react-scripts-ts eject" | |
}, | |
"devDependencies": { | |
"@types/aws-serverless-express": "^3.0.1", | |
"@types/express": "^4.11.1", | |
"@types/jest": "^22.2.3", | |
"@types/node": "^10.1.2", | |
"@types/react": "^16.3.14", | |
"@types/react-dom": "^16.0.5", | |
"@types/supertest": "^2.0.4", | |
"eslint": "^4.19.1", | |
"eslint-config-airbnb": "^16.1.0", | |
"eslint-config-prettier": "^2.9.0", | |
"eslint-config-standard": "^11.0.0", | |
"eslint-plugin-import": "^2.12.0", | |
"eslint-plugin-jsx-a11y": "^6.0.3", | |
"eslint-plugin-mocha": "^5.0.0", | |
"eslint-plugin-node": "^6.0.1", | |
"eslint-plugin-prettier": "^2.6.0", | |
"eslint-plugin-promise": "^3.7.0", | |
"eslint-plugin-react": "^7.8.2", | |
"eslint-plugin-standard": "^3.1.0", | |
"npm-run-all": "^4.1.3", | |
"prettier": "^1.12.1", | |
"react-app-rewired": "^1.5.2", | |
"supertest": "^3.1.0", | |
"tslint": "^5.10.0", | |
"tslint-config-airbnb": "^5.9.2", | |
"tslint-config-prettier": "^1.13.0", | |
"tslint-config-standard": "^7.0.0", | |
"tslint-language-service": "^0.9.9", | |
"tslint-plugin-prettier": "^1.3.0", | |
"tslint-react": "^3.6.0", | |
"typescript": "^2.8.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment