react-parcel-example

Minimum viable React app with Parcel Bundler

  • 所有者: jaredpalmer/react-parcel-example
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

React Parcel Example

A minimum viable React app with Parcel Bundler

What's inside?

  • parcel-bundler
  • react
  • react-dom
  • babel-preset-react-app
  • autoprefixer

Also checkout out the TypeScript branch

Getting started

Clone and install deps

git clone git@github.com:jaredpalmer/react-parcel-example.git
cd react-parcel-example
yarn
yarn start

Then open http://localhost:1234 and edit index.js and press save. Parcel
will automagically hot reload you files whenever you make changes.

Building for Production

npm run build

This will compile your JS and copy your index.html to the dist folder which
you can deploy wherever as a good ol' webpage.

CSS

Parcel uses PostCSS plugins to manage CSS assets.
I've included autoprefixer for vendor prefixing with the same setup as
create-react-app. You can find and modify the PostCSS setup in package.json.
If you'd rather keep your PostCSS setup in a dotfile, you can delete the
postcss key from package.json, and place its contents in a .postcssrc file
too.

Folder structure and relative paths

Keeping everything in the root directory obviously won't scale past a point.
Parcel is very flexible about folder structure, but there are a few gotchas.

Moving JS entry

When you do move index.js just make sure to update the <script> tag in
index.html so that it points to the correct relative path.

For example, if you want to move index.js to src/index.js, you would need
make the following change to index.html:

<   <script src="./index.js"></script>
---
>   <script src="./src/index.js"></script>

Moving index.html

If you want to move index.html, you will need to update your npm scripts in
package.json with the new relative path.

Deployment

Refer to the deployment guide in create-react-app, just note that you will
need to account for the fact that Parcel builds out to a dist directory, while
CRA builds to a build directory. You can make it identical by adding
--out-dir build to both start and build npm tasks in package.json.

主要指標

概覽
名稱與所有者jaredpalmer/react-parcel-example
主編程語言JavaScript
編程語言HTML (語言數: 3)
平台
許可證
所有者活动
創建於2017-12-05 19:25:58
推送於2018-03-05 01:29:02
最后一次提交2018-01-29 14:38:17
發布數0
用户参与
星數482
關注者數11
派生數58
提交數27
已啟用問題?
問題數11
打開的問題數5
拉請求數5
打開的拉請求數0
關閉的拉請求數4
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?