Modules to share across projects (enabling editing and commit)
npx create-react-app my-projetct --template typescriptcd my-project# init repository if needed# git init
git submodule add https://github.com/faiconqg/react-modules.git src/modulesnpm i @material-ui/core @material-ui/icons @nivo/line @ag-grid-community/all-modules @ag-grid-community/react lodash @types/lodash firebase mobx mobx-react-lite mobx-react-form moment prop-types react-dom-factories react-router-dom @types/react-router-dom validatorjs @types/react-swipeable-views react-swipeable-views @types/react-json-tree react-dropzone react-json-tree uuid
npm i -D eslint-plugin-prettier grunt grunt-bump prettier{
"start": "REACT_APP_VERSION=$npm_package_version react-scripts start", --edit"build": "REACT_APP_VERSION=$npm_package_version react-scripts build", --edit"pushModules": "git submodule foreach 'git push origin master'",
"pullModules": "git submodule foreach 'git pull origin master'",
"bump": "grunt bump:minor",
"bugfix": "grunt bump:patch",
"merge-master": "git checkout master && git merge develop",
"merge-develop": "git checkout develop && git merge master"
}mkdir .vscode &&echo'{ "editor.rulers": [80], "editor.tabCompletion": "on", "editor.tabSize": 2, "editor.trimAutoWhitespace": true, "editor.formatOnSave": true, "files.exclude": { "**/.DS_Store": true, "**/.git": true, "**/.hg": true, "**/.svn": true, "**/CVS": true, "dist": true }, "files.insertFinalNewline": true, "files.trimTrailingWhitespace": true, "typescript.tsdk": "./node_modules/typescript/lib", "eslint.run": "onSave", "eslint.nodePath": "./node_modules", "editor.codeActionsOnSave": { "source.fixAll.eslint": true }}'> .vscode/settings.json
echo'{ "extends": "react-app", "plugins": ["prettier"], "rules": { "prettier/prettier": "error" }}'> .eslintrcecho'{ "semi": false, "singleQuote": true, "printWidth": 80}'> .prettierrcecho'module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), bump: { options: { pushTo: 'origin' } } }) grunt.loadNpmTasks('grunt-bump')}'> Gruntfile.jsgit checkout -b developrm src/App.css src/App.test.tsx src/index.css src/App.tsx src/logo.svgmkdir src/components src/components/atoms src/components/molecules src/components/organims src/components/templates{
"appName": "The App Name",
"companyName": "The Company Name",
"companyUrl": "https://www.website.com",
"allowNewUsers": true| false,"displayAppNameInMenuHeader": false
}This information can be found on the firebase console. Add Firebase to your JavaScript project.
{
"apiKey": "********************************",
"authDomain": "********.firebaseapp.com",
"databaseURL": "https://******.firebaseio.com",
"projectId": "***",
"storageBucket": "****.appspot.com",
"messagingSenderId": "*****",
"appId": "*****",
"measurementId": "G-Q6EX9R1BP8"
}{
"compilerOptions": {
"baseUrl": "./src/",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["src"]
}root.tsx in src folder
importReactfrom'react'importSyncfrom'@material-ui/icons/Sync'importAutoRoutefrom'modules/libs/AutoRoute'importSamplefrom'modules/pages/Sample'importSampleTabfrom'modules/pages/SampleTab'importSimplePagefrom'modules/components/templates/SimplePage'importSampleFeaturefrom'modules/components/templates/SampleFeature'constRoot: React.FC=()=>{return(<AutoRouteheaderButtons={[{icon: <Sync/>,label: 'Test Button',action: ()=>console.log('button click')}]}featureRoutes={[{path: '',label: 'Overview',icon: 'home',page: Sample}]}routes={[{label: 'Test',routes: [{path: 'sample_simple',label: 'Simple',icon: 'cloud_off',page: ()=><SimplePageheader="Test">Test</SimplePage>}]},{label: 'Samples',routes: [{path: 'sample_tab',label: 'Tabs',icon: 'calendar_today',page: SampleTab},{path: 'sample_feature',label: 'Feature',icon: 'star',page: SampleFeature}]}]}/>)}exportdefaultRootCreate a pages folder in src and configure this pages in the root.tsx file.
importReactfrom'react'importReactDOMfrom'react-dom'importRootfrom'root'importAppfrom'modules/pages/App'importconfigfrom'config.json'import{blue,deepOrange}from'@material-ui/core/colors'importcreateThemefrom'modules/utils/misc/CreateTheme'consttheme=createTheme(blue,deepOrange)ReactDOM.render(<Appconfig={Object.assign(config,{apiUrl: process.env.REACT_APP_API_URL,appIcon: require('resources/images/logo.png')})}firebaseConfig={firebaseConfig}theme={theme}><Root/></App>,document.getElementById('root'))Create a .env file and put the API URL, more docs soon.
REACT_APP_API_URL=http://localhost:3001- Replace
logo192.pngandlogo512.pngandfavicon.icowith your logos, tip: use favicon-generator to convert PNG to ico - Edit
short_name,nameandtheme_colorin manifest.json - Replace meta in
index.html
<meta name="viewport" content="width=device-width,initial-scale=1 maximum-scale=1.0,user-scalable=0,minimum-scale=1,viewport-fit=cover"/>- Add fonts above title in
index.html
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/><link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>- Replace
titleinindex.html