Master Branch Live Preview
Develop Branch Live Preview
Storybook Documentation
Test status
Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files the blazing fast app generator for React. Integrating with Typescript for type checking as well as Jest for unit testing. Provide smooth development experience and CI/CD pipeline with CircleCI and Netlify built in.
-
Clone this Repo
# clone this repo via github link git clone https://github.com/tripheo0412/jamstack-typescript-boilerplate.git
-
Install all packages
Using either yarn/npm install
cd jamstack-typescript-boilerplate yarn
or
cd jamstack-typescript-boilerplate npm install
-
Add Contentful
Sign up account on Contentful.
Create new space.
Go to Space's setting -> Api keys -> Generate new Personal Access Tokens -> Add token to .env file.
CONTENTFUL_SPACE_ID <your generated Contentful personal access token> CONTENTFUL_ACCESS_TOKEN <your Space ID>
Go to Space's setting -> Add Space's ID to .env file.
CONTENTFUL_SPACE_ID <your generated Contentful personal access token> CONTENTFUL_ACCESS_TOKEN <your Space ID>
Go to gatsby-config.js remove comment on contentful plugin.
Add Gatsby-Contentful-Plugin
yarn add gatsby-source-contentful
Voila! You are ready to go!
-
Setting up CI/CD
Registered your account on CircleCI and Netlify.
Get Netlify Site ID + generate Netlify personal access token.
Connect project github repo to CircleCI, go to project settings, click on environment variables and add 2 variables.
NETLIFY_ACCESS_TOKEN <your generated Netlify personal access token> NETLIFY_SITE_ID <your Netlify Site ID>
After setting this up, everytime you push, CircleCI will check for lint + testing error, if passed you can click details in CircleCI check and see the Web URL deployed on Netlify.
Note that for master branch, CircleCI will build the App and release to Netlify with tag --prod for Production deployment.
-
Open the source code and start editing!
yarn start
or
npm run start
Your site is now running at
http://localhost:8000
!Note: You'll also see a second link:
http://localhost:8000/___graphql
. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the Gatsby tutorial.Open the
jamstack-typescript-boilerplate
directory in your code editor of choice and editsrc/pages/index.js
. Save your changes and the browser will update in real time!
A quick look at the top-level files and directories you'll see in this boilerplate.
.
βββ .circleci/config.yml
βββ .storybook
βββ config
βββ node_modules
βββ src
βββ .gitignore
βββ .prettierrc
βββ gatsby-browser.js
βββ gatsby-config.js
βββ gatsby-node.js
βββ gatsby-ssr.js
βββ jest-preprocess.js
βββ jest.config.js
βββ LICENSE
βββ loadershim.js
βββ README.md
βββ package.json
βββ tsconfig.json
βββ tslint.json
βββ yarn.lock/package-lock.json
-
/circleci
: This directory contains CircleCI configuration file. Note that there are 2 types of job: build (for every push to any branch beside master) and release (for master branch - production deployment). -
.storybook/
: This directory contains all the configuration files for Storybook. -
/config
: This directory contains all the configuration files for Jest testing. -
/node_modules
: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. -
/src
: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template.src
is a convention for βsource codeβ. -
.gitignore
: This file tells git which files it should not track / not maintain a version history for. -
.prettierrc
: This is a configuration file for Prettier. Prettier is a tool to help keep the formatting of your code consistent. -
gatsby-browser.js
: This file is where Gatsby expects to find any usage of the Gatsby browser APIs (if any). These allow customization/extension of default Gatsby settings affecting the browser. -
gatsby-config.js
: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins youβd like to include, etc. (Check out the config docs for more detail). -
gatsby-node.js
: This file is where Gatsby expects to find any usage of the Gatsby Node APIs (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. -
gatsby-ssr.js
: This file is where Gatsby expects to find any usage of the Gatsby server-side rendering APIs (if any). These allow customization of default Gatsby settings affecting server-side rendering. -
jest-preprocess.js
: This file contains babel options to build gatsby project for Jest testing -
jest.config.js
: This file contains all of Jest configurations. -
LICENSE
: This boilerplate is licensed under the MIT license. -
loadershim.js
: This files contains loader setting for Jest. -
package.json
: A manifest file for Node.js projects, which includes things like metadata (the projectβs name, author, etc). This manifest is how npm knows which packages to install for your project. -
README.md
: A text file containing useful reference information about your project. -
tsconfig.json
: This file contains all of typescript configurations for type checking. -
tslint.json
: This file contains all of typescript linting configurations, integrating with prettier. -
yarn.lock/package-lock.json
(Seepackage.json
below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. (You wonβt change this file directly).
- NodeJS.
- Storybook.
- IDE of your choice.
- Command Line Tools.
Run test suites:
npm run test
or
yarn test
In watch mode:
npm run test:watch
or
yarn test:watch
Format code and write based on Prettier rules
npm run format
or
yarn format