|
| 1 | +# web-app-template |
| 2 | + |
| 3 | +A framework-agnostic web app template. |
| 4 | + |
| 5 | +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) but also ejected with dependencies like React removed. |
| 6 | + |
| 7 | +[See demo.](https://remarkablemark.github.io/web-app-template/) |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +- [Node.js 8.6+](https://nodejs.org/en/download/) |
| 12 | +- [npm 5.3+](https://www.npmjs.com/get-npm) or [Yarn 1+](https://yarnpkg.com/lang/en/docs/install/) |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +Clone repository: |
| 17 | + |
| 18 | +```sh |
| 19 | +$ git clone https://github.com/remarkablegames/web-app-template.git |
| 20 | +``` |
| 21 | + |
| 22 | +Rename project: |
| 23 | + |
| 24 | +```sh |
| 25 | +$ mv web-app-template my-app |
| 26 | +$ cd my-app |
| 27 | +$ git grep -l web-app-template | xargs sed -i '' -e 's/web-app-template/my-app/g' |
| 28 | +$ git grep -l 'Web App Template' | xargs sed -i '' -e 's/Web App Template/My App/g' |
| 29 | +``` |
| 30 | + |
| 31 | +You should also update the following files: |
| 32 | + |
| 33 | +- [ ] README.md |
| 34 | +- [ ] package.json |
| 35 | +- [ ] public/index.html |
| 36 | +- [ ] public/manifest.json |
| 37 | +- [ ] src/index.js |
| 38 | + |
| 39 | +Install dependencies: |
| 40 | + |
| 41 | +```sh |
| 42 | +# with npm |
| 43 | +$ npm install |
| 44 | + |
| 45 | +# or with yarn |
| 46 | +$ yarn |
| 47 | +``` |
| 48 | + |
| 49 | +Initialize new repository: |
| 50 | + |
| 51 | +```sh |
| 52 | +$ rm -rf .git |
| 53 | +$ git init |
| 54 | +``` |
| 55 | + |
| 56 | +Make first commit: |
| 57 | + |
| 58 | +```sh |
| 59 | +$ git add . |
| 60 | +$ git commit -m "feat: initialize project from web-app-template" |
| 61 | +``` |
| 62 | + |
| 63 | +> Commit messages follow the [Conventional Commits](https://conventionalcommits.org/) format. (Used when releasing a new version.) |
| 64 | +
|
| 65 | +Don't forget to [push the local repository to GitHub](https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/) or to another remote repository: |
| 66 | + |
| 67 | +```sh |
| 68 | +$ git remote add origin <remote-repository-url> |
| 69 | +$ git push origin -u origin master |
| 70 | +``` |
| 71 | + |
| 72 | +## Scripts |
| 73 | + |
| 74 | +Start development server: |
| 75 | + |
| 76 | +```sh |
| 77 | +# with npm |
| 78 | +$ npm start |
| 79 | + |
| 80 | +# or with yarn |
| 81 | +$ yarn start |
| 82 | +``` |
| 83 | + |
| 84 | +Build production artifacts: |
| 85 | + |
| 86 | +```sh |
| 87 | +# with npm |
| 88 | +$ npm run build |
| 89 | + |
| 90 | +# or with yarn |
| 91 | +$ yarn build |
| 92 | +``` |
| 93 | + |
| 94 | +> **Note**: Make sure the `"homepage"` field in `package.json` is correct. |
| 95 | +
|
| 96 | +Create a release using [standard-version](https://github.com/conventional-changelog/standard-version): |
| 97 | + |
| 98 | +```sh |
| 99 | +# with npm |
| 100 | +$ npm run release |
| 101 | + |
| 102 | +# or with yarn |
| 103 | +$ yarn release |
| 104 | +``` |
| 105 | + |
| 106 | +Deploy to [GitHub Pages](https://pages.github.com/): |
| 107 | + |
| 108 | +```sh |
| 109 | +# with npm |
| 110 | +$ npm run deploy |
| 111 | + |
| 112 | +# or with yarn |
| 113 | +$ yarn deploy |
| 114 | +``` |
| 115 | + |
| 116 | +It force pushes the `./build/` directory to the remote repository's `gh-pages` branch. |
| 117 | + |
| 118 | +## Environment Variables |
| 119 | + |
| 120 | +Environment variables work the same as [create-react-app](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables) except the custom environment variables begin with `APP_` instead of `REACT_APP_`. |
| 121 | + |
| 122 | +## Test |
| 123 | + |
| 124 | +There are no tests, just linting: |
| 125 | + |
| 126 | +```sh |
| 127 | +# with npm |
| 128 | +$ npm run lint |
| 129 | +$ npm run lint:fix |
| 130 | + |
| 131 | +# with yarn |
| 132 | +$ yarn lint |
| 133 | +$ yarn lint:fix |
| 134 | +``` |
| 135 | + |
| 136 | +Feel free to add a [testing framework](https://github.com/sorrycc/awesome-javascript#testing-frameworks). |
| 137 | + |
| 138 | +For manual testing, you can build the (production) app locally: |
| 139 | + |
| 140 | +```sh |
| 141 | +# git stash |
| 142 | +$ sed -i '' '/homepage/d' package.json |
| 143 | +$ npm run build # yarn build |
| 144 | +# git checkout -- package.json |
| 145 | +# git stash pop |
| 146 | +``` |
| 147 | + |
| 148 | +Start a local server: |
| 149 | + |
| 150 | +```sh |
| 151 | +$ cd build |
| 152 | +$ python -m SimpleHTTPServer |
| 153 | +# press `Ctrl + C` to stop the server |
| 154 | +``` |
| 155 | + |
| 156 | +And access it on `localhost:8000`: |
| 157 | + |
| 158 | +```sh |
| 159 | +$ open http://localhost:8000 |
| 160 | +``` |
| 161 | + |
| 162 | +## Layout |
| 163 | + |
| 164 | +Directory structure (dotfiles are omitted): |
| 165 | + |
| 166 | +```sh |
| 167 | +$ tree -I 'build|node_modules' |
| 168 | +. |
| 169 | +βββ LICENSE |
| 170 | +βββ README.md |
| 171 | +βββ config |
| 172 | +βΒ Β βββ env.js |
| 173 | +βΒ Β βββ paths.js |
| 174 | +βΒ Β βββ webpack.config.js |
| 175 | +βΒ Β βββ webpackDevServer.config.js |
| 176 | +βββ package.json |
| 177 | +βββ public |
| 178 | +βΒ Β βββ index.html |
| 179 | +βΒ Β βββ manifest.json |
| 180 | +βββ scripts |
| 181 | +βΒ Β βββ build.js |
| 182 | +βΒ Β βββ start.js |
| 183 | +βββ src |
| 184 | + βββ index.css |
| 185 | + βββ index.js |
| 186 | + βββ serviceWorker.js |
| 187 | + |
| 188 | +4 directories, 14 files |
| 189 | +``` |
| 190 | + |
| 191 | +## Diff |
| 192 | + |
| 193 | +Compared to `create-react-app`, the additional dependencies saved to `package.json` are: |
| 194 | + |
| 195 | +- [@commitlint/{cli,config-conventional}](https://github.com/conventional-changelog/commitlint) |
| 196 | +- [eslint-plugin-babel](https://github.com/babel/eslint-plugin-babel) |
| 197 | +- [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) |
| 198 | +- [gitploy](https://github.com/remarkablemark/gitploy) |
| 199 | +- [husky](https://github.com/typicode/husky) |
| 200 | +- [jsonlint](https://github.com/zaach/jsonlint) |
| 201 | +- [lint-staged](https://github.com/okonet/lint-staged) |
| 202 | +- [prettier](https://github.com/prettier/prettier) |
| 203 | +- [standard-version](https://github.com/conventional-changelog/standard-version) |
| 204 | + |
| 205 | +## License |
| 206 | + |
| 207 | +[MIT](LICENSE) |
0 commit comments