Parcel 中文參考文檔
/ 生產(chǎn)環(huán)境
生產(chǎn)環(huán)境
生產(chǎn)環(huán)境
當(dāng)需要打包應(yīng)用程序用于生產(chǎn)環(huán)境時(shí),可以使用 Parcel 的生產(chǎn)模式。
parcel build entry.js
這將禁用 監(jiān)聽(tīng)(watch) 模式和模塊熱更換,所以它只會(huì)構(gòu)建一次。它還會(huì)開(kāi)啟 minifier 用于壓縮輸出包文件的大小。Parcel使用的 minifiers 包括用于 JavaScript 的 uglify-es,用于 CSS 的 cssnano,和用于 HTML 的 htmlnano。
啟用生產(chǎn)模式還需要設(shè)置 NODE_ENV = production 環(huán)境變量。 像 React 這樣的大型庫(kù)有開(kāi)發(fā)調(diào)試功能,通過(guò)設(shè)置這個(gè)環(huán)境變量來(lái)禁用調(diào)試功能,從而使生產(chǎn)的構(gòu)建更小更快。
選項(xiàng)
設(shè)置輸出目錄
默認(rèn): "dist"
parcel build entry.js --out-dir build/output 或者 parcel build entry.js -d build/output
root - build - - output - - - entry.js
設(shè)置要提供服務(wù)的公共 URL
默認(rèn): --out-dir option
parcel build entry.js --public-url ./
將輸出:
<link rel="stylesheet" type="text/css" href="1a2b3c4d.css"> or <script src="e5f6g7h8.js"></script>
禁用壓縮
默認(rèn): minification enabled
parcel build entry.js --no-minify
禁用文件系統(tǒng)緩存
默認(rèn): cache enabled
parcel build entry.js --no-cache