凯旋 发表于 2021-6-19 13:25:23

前端打包的过程(Ubuntu 20.04+Nodejs+Yarn)

软件:
操作系统为Ubuntu 20.04.2
Nodejs v10.19.0
Yarn v1.22.5

作为一个懒人,比较喜欢ubuntu的apt。半路出家,不是IT专业。

安装Node.js
sudo apt update
sudo apt install nodejs

安装Yarncurl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key addecho "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.listsudo apt update
sudo apt install yarn打包前,需要进入到web前台的目录中,默认为JSH_ERP/jshERP-web目前中
执行yarn install会安装各种依赖包,这个过程依赖网络速度及源的质量(可能提示让执行yarn upgrade升级)
安装完成,执行:yarn serve过程中,会有warning信息,不过我个人感觉警告信息是可以忽略的,所以我没有去一一解决这个warning信息,但是最后的提示要特别小心:

Failed to resolve loader: sass-loader
You may need to install it.

App running at:
- Local:   http://localhost:3000/
- Network: http://10.0.4.8:3000/

Note that the development build is not optimized.
To create a production build, run yarn build.
不要安装sass-loader。我在开发文件package.json中,也没有看到sass的信息。在一开始的尝试中,我使用npm安装了sass-loader, node-sass, cache-loader, 导致了一大堆的问题。
在这个界面,系统一直没有退出,需要按ctrl+c来退出,才可以执行yarn build。以前没有玩过node.js, 完全懵。
然后执行yarn build结果会保存在dist目录中
构建过程有点慢,需要内在在1G以上,我用阿里云香港的轻量1G的结果如下:
Images and other types of assets omitted.

DONEBuild complete. The dist directory is ready to be deployed.
INFOCheck out deployment instructions at https://cli.vuejs.org/guide/deployment.html
                                 
Done in 214.59s.
使用北美的一个VPS的结果要好得多:
Images and other types of assets omitted.

DONEBuild complete. The dist directory is ready to be deployed.
INFOCheck out deployment instructions at https://cli.vuejs.org/guide/deployment.html
                                 
Done in 32.04s.

jishenghua 发表于 2021-6-19 21:18:47

写的不错,看来是华夏ERP的铁粉,给你加个精华

格叻精神 发表于 2021-7-9 12:20:05

点个赞:lol
页: [1]
查看完整版本: 前端打包的过程(Ubuntu 20.04+Nodejs+Yarn)