├── .env.example ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── .husky ├── pre-commit └── pre-push ├── .lintstagedrc.json ├── .prettierignore ├── .prettierrc.json ├── .stylelintignore ├── .stylelintrc.json ├── LICENSE ├── README.md ├── index.html ├── package-lock.json ├── package.json ├── src ├── app │ ├── App.jsx │ ├── App.module.css │ ├── components │ │ ├── Button │ │ │ ├── Button.jsx │ │ │ └── Button.module.css │ │ └── Welcome │ │ │ ├── Welcome.jsx │ │ │ └── Welcome.module.css │ ├── favicon.svg │ ├── globals.css │ ├── logo.svg │ └── main.jsx ├── lib │ └── router.js └── server.js └── vite.config.js /.env.example: -------------------------------------------------------------------------------- 1 | PORT=3001 -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist 4 | dist-ssr 5 | *.local 6 | .eslintcache -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "node": true 6 | }, 7 | "extends": ["eslint:recommended", "prettier", "plugin:react/recommended"], 8 | "parser": "babel-eslint", 9 | "parserOptions": { 10 | "ecmaVersion": 12, 11 | "sourceType": "module" 12 | }, 13 | "plugins": ["react-hooks"], 14 | "rules": {}, 15 | "settings": { 16 | "react": { 17 | "version": "17.0" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist 4 | dist-ssr 5 | *.local 6 | .eslintcache -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged --config .lintstagedrc.json 5 | -------------------------------------------------------------------------------- /.husky/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npm test 5 | -------------------------------------------------------------------------------- /.lintstagedrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.{js,jsx,ts,tsx}": "eslint --fix --cache", 3 | "*.css": "stylelint --fix", 4 | "*.{js,jsx,ts,tsx,css,html,json,md,mdx}": "prettier --write" 5 | } 6 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist 4 | dist-ssr 5 | *.local 6 | .eslintcache -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } 4 | -------------------------------------------------------------------------------- /.stylelintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist 4 | dist-ssr 5 | *.local 6 | .eslintcache -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["stylelint-config-standard", "stylelint-config-prettier"] 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Leon Machens 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vite React Express Boilerplate 2 | 3 | > Quickly bootstrap a new project with Vite React Express Boilerplate. 4 | 5 | This boilerplate is a fork of [lmachens/vite-boilerplate](https://github.com/lmachens/vite-boilerplate), but replaces TypeScript with JavaScript and removes Storybook. 6 | 7 | This boilerplate contains all the tools you need to build a modern web app with JavaScript, React, Vite, and Express. 8 | You can use it to quickly bootstrap your project. 9 | 10 | ESLint, stylelint, prettier, husky and lintstaged are configured to give you a solid development experience. 11 | 12 | ## Installing / Developing 13 | 14 | First, [create a repository from this template](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/creating-a-repository-from-a-template). 15 | 16 | Now you are ready to go: 17 | 18 | ```shell 19 | npm install 20 | ``` 21 | 22 | This will install the dependencies required to run the boilerplate. 23 | 24 | ```shell 25 | npm run dev 26 | ``` 27 | 28 | Boom! These scripts run your server and client in development mode. 29 | 30 | The default PORTS are: 31 | 32 | - `3001` for the server 33 | - `3000` for the client 34 | 35 | If you don't like to call all scripts at once, you can also run: 36 | 37 | ```shell 38 | npm run server:dev 39 | npm run client:dev 40 | ``` 41 | 42 | You can configure the server port by setting the `PORT` environment variable. Creating a `.env` file is supported. You can copy `.env.example` to `.env`. 43 | 44 | | KEY | VALUE | 45 | | ---- | ------------------------------------------------------------- | 46 | | PORT | (Optional) Port for the server environment (defaults to 3001) | 47 | 48 | ## Building 49 | 50 | To build the project, run: 51 | 52 | ```shell 53 | npm run build 54 | ``` 55 | 56 | This will build the client and server. 57 | 58 | ```shell 59 | npm start 60 | ``` 61 | 62 | In production, you have a single server serving everything. 63 | 64 | `/api/*` is the API endpoint. 65 | `/*` is the client. 66 | 67 | ## Tests 68 | 69 | A test runner is not installed (right now). But ESLint and Prettier are checked on commit and pushed thanks to husky and lintstaged. 70 | 71 | ## Licensing 72 | 73 | MIT 74 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |17 | 20 |
21 |
22 | Edit App.jsx
and save to test HMR updates.
23 |
25 | 31 | Learn React 32 | 33 | {' | '} 34 | 40 | Vite Docs 41 | 42 |
43 |{message}
; 14 | } 15 | 16 | export default Welcome; 17 | -------------------------------------------------------------------------------- /src/app/components/Welcome/Welcome.module.css: -------------------------------------------------------------------------------- 1 | .message { 2 | font-weight: bold; 3 | } 4 | -------------------------------------------------------------------------------- /src/app/favicon.svg: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /src/app/globals.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/app/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/main.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './globals.css'; 4 | import App from './App'; 5 | 6 | ReactDOM.render( 7 |