Parcel 使用前需先安裝套件。

可以透過 yarn。

yarn global add parcel-bundler

或是透過 npm 安裝。

npm install -g parcel-bundler

Parcel - Getting started

安裝完準備要進行打包的程式。

Parcel - Getting started

Index.html 檔案內容為:

<html>
<body>
  <script src="./index.js"></script>
</body>
</html>

Index.js 檔案內容為:

console.log("hello world");

調用 Parcel 命令進行編譯並運行網站服務。

parcel [WebFile]

Parcel - Getting started

編譯後的檔案會產生在 dist 目錄下。

Parcel - Getting started

連至網站可看到打包後運行起來的樣子。

Parcel - Getting started

要退出網站服務的話,按下熱鍵 Ctrl + C,鍵入 Y 後 Enter 即可。

Parcel - Getting started