Skip to content

Latest commit

Β 

History

History
76 lines (59 loc) Β· 2.98 KB

01-Setup.md

File metadata and controls

76 lines (59 loc) Β· 2.98 KB

Setup

In this section we'll go over

  • How to clone repository
  • Yarn commands
  • Directory structure

Clone repository

You can clone this repository by running the following command:

git clone https://github.com/Tomburgs/pwa-boilerplate

After this, run the yarn install command to install node modules.

Yarn commands

  • yarn development - Start NextJS development server, you might need to run build before first run.
  • yarn build - Create build files.
  • yarn start - Start NextJS production server.
  • yarn eslint - Run ESLint tests.

Project structure

.
β”œβ”€β”€ next-env.d.ts
β”œβ”€β”€ next.config.js - NextJS config file, includes loaders, plugins, env variable definitions & other things.
β”œβ”€β”€ package.json
β”œβ”€β”€ public - Static file directory, read more about it here: https://nextjs.org/docs/basic-features/static-file-serving
β”‚            Files such as favicon, manifest, robots.txt & logos can be found here.
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ assets - Includes all svg icons
β”‚Β Β  β”œβ”€β”€ components - React component directory
β”‚Β Β  β”œβ”€β”€ contexts - React contexts
β”‚Β Β  β”œβ”€β”€ hooks - React hooks
β”‚Β Β  β”œβ”€β”€ pages - NextJS pages, commonly files here will directly link to src/routes directory
β”‚Β Β  β”œβ”€β”€ routes - React route components, more about the difference between this & src/pages below
β”‚Β Β  β”œβ”€β”€ stores - Redux stores
β”‚Β Β  β”œβ”€β”€ styles - Main styles, font helper functions, variables & more
β”‚Β Β  β”œβ”€β”€ sw - Service Worker directory
β”‚Β Β  β”œβ”€β”€ utils - Util functions, includes such things as localStorage abstraction, getWindowProperty method, etc.
β”‚Β Β  └── config.ts - Config file, this includes such things as theme-color meta data & iOS status bar style definitions.
β”œβ”€β”€ tsconfig.json
└── yarn.lock

Removing demo files

You can safely remove the following files & directories. These were only necessary to showcase features such as caching:

  • src/pages/api
  • src/pages/[page].tsx
  • src/pages/pages.tsx
  • src/routes/pageList
  • public/api

After this you will have a couple of issues:

  • The homepage will have infinite placeholders where content used to be.
  • There will be infinite placeholders on the sidebar under "Pages" text.
  • The "Pages" header item will link you to a 404 page.

In order to fix these, you will want to modify the following files:

  • src/routes/page/Page.component.tsx - This file is responsible for the infinite placeholders on Homepage.
  • src/components/sidebar/Sidebar.component.tsx - This file is responsible for the infinite placeholders on the Sidebar.
  • src/components/pages - After modifying Sidebar to not use it, this component can be safely removed.
  • src/components/header/items/Items.component.tsx - Remove "Pages" link.
  • src/stores/index.ts - Modify this to not include the pages reducer anymore.
  • src/stores/pages - Remove the pages redux store.
  • src/hooks/page - These were the hooks responsible for interacting with & fetching the page content.