-

parcel使用:打包html、js、css(图文教程)

Parcel 使用 worker 进程去启用多核编译。同时有文件系统缓存,即使在重启构建后也能快速再编译。

parcel安装
npm init创建package.json
npm install -g parcel-bundler
parcel案例
使用parcel打包一个网站,并运行查看效果
test.js文件
let test = { a:1,b:2 }

module.exports = test;

test2.js文件
import testObj from "./test.js";

console.log(testObj.a);

package.json文件
{
  "name": "parcel",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "parcel test2.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

运行:cmd >> npm start

运行:cmd >> parcel test2.js