手册
目录
收藏804
分享
阅读16437
更新时间2022-04-20
生产环境
当需要打包应用程序用于生产环境时,可以使用 Parcel 的生产模式。
parcel build entry.js
这将禁用 监听(watch) 模式和模块热更换,所以它只会构建一次。它还会开启 minifier 用于压缩输出包文件的大小。Parcel使用的 minifiers 包括用于 JavaScript 的 uglify-es,用于 CSS 的 cssnano,和用于 HTML 的 htmlnano。
启用生产模式还需要设置 NODE_ENV = production 环境变量。 像 React 这样的大型库有开发调试功能,通过设置这个环境变量来禁用调试功能,从而使生产的构建更小更快。
选项
设置输出目录
默认: "dist"
parcel build entry.js --out-dir build/output 或者 parcel build entry.js -d build/output
root - build - - output - - - entry.js
设置要提供服务的公共 URL
默认: --out-dir option
parcel build entry.js --public-url ./
将输出:
<link rel="stylesheet" type="text/css" href="1a2b3c4d.css"> or <script src="e5f6g7h8.js"></script>
禁用压缩
默认: minification enabled
parcel build entry.js --no-minify
禁用文件系统缓存
默认: cache enabled
parcel build entry.js --no-cache
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.2万人学习
共49课时
77万人学习
共29课时
61.7万人学习
共25课时
39.3万人学习
共43课时
70.9万人学习
共25课时
61.6万人学习
共22课时
23万人学习
共28课时
33.9万人学习
共89课时
125万人学习