Platform configurations using the latest SDKs
...
dependencies {
...
classpath 'com.android.tools.build:gradle:3.0.0'
}
android {
compileSdkVersion 26
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 26
}
...
}
dependencies {
...
implementation 'com.android.support:appcompat-v7:26.1.0'
...
}
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
org.gradle.jvmargs=-Xmx1536m
Add dev dependencies
yarn add -D babel-eslint babel-preset-flow babel-plugin-transform-remove-console eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react flow-bin prettier-eslint
Add scripts to package.json
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"lint": "eslint .",
"prettier": "eslint . --fix",
"flow start": "flow start",
"flow stop": "flow stop",
"flow status": "flow status",
"flow coverage": "flow coverage"
},
Add/Update .babelrc
{
"presets": ["react-native", "flow"],
"retainLines": true,
"env": {
"production": {
"plugins": ["transform-remove-console"]
}
}
}
Add/Update .eslintrc
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": ["react", "jsx-a11y", "import"],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"jest": true,
"node": true,
"browser": true
},
"rules": {
"semi": 0,
"react/jsx-filename-extension": 0,
"linebreak-style": 0,
"import/no-extraneous-dependencies": 0,
"no-use-before-define": 0
}
}
Add/Update .prettierrc
{
"printWidth": 80,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "es5",
"semi": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"parser": "flow",
"useTabs": true
}
Add/Update preferences
{
"editor.formatOnSave": true,
"flow.useNPMPackagedFlow": true,
"javascript.format.enable": false,
"javascript.validate.enable": false,
"prettier.eslintIntegration": true
}
Add/Update .gitignore
# VSCODE
.vscode/
# ENV
.env
.env.*
Use Haul Package by Callstack
yarn add -D haul
Add this just before apply from: "../../node_modules/react-native/react.gradle"
project.ext.react = [
cliPath: "node_modules/haul/bin/cli.js"
]
This will add a webpack.haul.js which can be customized
yarn haul init
"start:android": "haul start --platform android",
"start:android-prod": "haul start --platform android --dev false --minify true",
"start:ios": "haul start --platform ios",
"start:ios-prod": "haul start --platform ios --dev false --minify true"
In case of using single entry component, add this to the index.js, else refer to Haul documentation.
import 'haul/hot'
yarn haul start -- --platform android|ios
react-native run-android|ios