美文网首页
Parcel之build方法

Parcel之build方法

作者: 是周大侠啊 | 来源:发表于2022-01-07 16:16 被阅读0次

build是什么

build的作用

如何进行build

step1

首先清空dist文件夹

rm -rf dist

step2

方法一:parcel build 路径(文件夹)/文件 --no-minify --pubilc-url 相对路径

parcel build src/index.html --no-minify --public-url ./

方法二:parcel build 路径(文件夹)/文件 --no-minify --pubilc-url github绝对路径

parcel build src/index.html --no-minify --pubilc-url https://frankfang.github.io/nav-1/dist

step3

  • 查看build中index.html文件,查看路径是否正确
  • 路径前面不能存在./
image

step4

git操作(不清楚的小伙伴请查看我的之前的文章)
注意:进行到git init即可,先不要提交

step5(视情况操作:如果存在多余文件)

  • 根目录创建.gitignore文件
/.cache/
/dist/
/node_modules/
/.idea/

step6

本地git仓库操作:
操作添加-提交-查看

git add .
git commit -m "版本号/描述"
git status

step7

远程git仓库操作 :
建立联系-推送到远程git仓库

git remote add origin git@github.com:用户名/ 远程仓库
git push -u origin master

git remote add origin git@github.com:Xinjn / static-server.git
 git push -u origin master

封装build

yarn build一键发布

step1

  • 如果存在package.json文件,直接跳过看step2
  • 如果不存在通过代码新建package.json文件
yarn init -y

step2

在package.json开头写入

"script":{
  "build":"rm -rf dist && parcel build src/indiex.html --no-minify --public-url ./"
},

step3

完成!!一键build

yarn buld

相关文章

网友评论

      本文标题:Parcel之build方法

      本文链接:https://www.haomeiwen.com/subject/zywecrtx.html