洞察纵观鸿蒙next版本,如何凭借FinClip加强小程序的跨平台管理,确保企业在数字化转型中的高效运营和数据安全?
679
2022-11-30
Jenkins 常用的项目构建工具集成 04 npm yarn
npm
前端项目的构建使用npm,前端项目-node.js 官网:Download | Node.js
安装npm
wget xf node-v14.16.1-linux-x64.tar.xz -C /usr/local/[root@zeyang-nuc-service node-v14.16.1-linux-x64]# vi /etc/profileexport NODE_HOME=/usr/local/node-v14.16.1-linux-x64export PATH=$NODE_HOME/bin:$PATH[root@zeyang-nuc-service node-v14.16.1-linux-x64]# source /etc/profile[root@zeyang-nuc-service node-v14.16.1-linux-x64]# node -vv14.16.1[root@zeyang-nuc-service node-v14.16.1-linux-x64]# npm -v6.14.12
通过下面的命令,初始化一个vue项目
[root@zeyang-nuc-service node-v14.16.1-linux-x64]# npm install -g vue+ vue@2.6.12added 1 package from 1 contributor in 3.342s[root@zeyang-nuc-service node-v14.16.1-linux-x64]# vue-init webpack vuedemo? Project name vuedemo? Project description A Vue.js project? Author adminuser <2560350642@qq.com>? Vue build standalone? Install vue-router? No? Use ESLint to lint your code? No? Set up unit tests No? Setup e2e tests with Nightwatch? No? Should we run `npm install` for you after the project has been created? (recommended) npm vue-cli · Generated "vuedemo".
这个是一个vue前端的项目,怎么打包呢?先去install去安装其依赖,没问题之后再去run buid去打包
常用命令
npm install
root@jenkins-master devops-web-service-master]# npm install[ ......] / extract:caniuse-db: sill extract caniuse-db@1.0.30001208 extracted to /root/devops-web-service-master/node_m> core-js@2.6.12 postinstall /root/devops-web-service-master/node_modules/core-js> node -e "try{require('./postinstall')}catch(e){}"Thank you for using core-js ( ) for polyfilling JavaScript standard library!The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: > > Also, the author of core-js ( ) is looking for a good job -)> ejs@2.7.4 postinstall /root/devops-web-service-master/node_modules/ejs> node ./postinstall.jsThank you for installing EJS: built with the Jake JavaScript build tool (uglifyjs-webpack-plugin@0.4.6 postinstall /root/devops-web-service-master/node_modules/webpack/node_modules/uglifyjs-webpack-plugin> node lib/post_install.jsnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})added 1272 packages from 675 contributors and audited 1279 packages in 169.809s47 packages are looking for funding run `npm fund` for detailsfound 60 vulnerabilities (3 low, 50 moderate, 7 high) run `npm audit fix` to fix them, or `npm audit` for details
然后去打包
[root@jenkins-master devops-web-service-master]# npm run build> vuedemo@1.0.0 build /root/devops-web-service-master> node build/build.js?.building for production...(node:28710) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency(Use `node --trace-warnings ...` to show where the warning was created)(node:28710) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'find' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'head' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'set' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'test' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'to' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency(node:28710) Warning: Accessing non-existent property 'which' of module exports inside circular dependencyHash: c5df099009c25bc0dbcaVersion: webpack 3.12.0Time: 11333ms Asset Size Chunks Chunk Names static/js/app.2f2e5edd9af2c59aa514.js 11.5 kB 0 [emitted] app static/js/vendor.0aad2172a75b8ed4f46c.js 94.8 kB 1 [emitted] vendor static/js/manifest.2ae2e69a05c33dfc65f8.js 857 bytes 2 [emitted] manifest static/css/app.30790115300ab27614ce176899523b62.css 432 bytes 0 [emitted] appstatic/css/app.30790115300ab27614ce176899523b62.css.map 797 bytes [emitted] static/js/app.2f2e5edd9af2c59aa514.js.map 21.7 kB 0 [emitted] app static/js/vendor.0aad2172a75b8ed4f46c.js.map 494 kB 1 [emitted] vendor static/js/manifest.2ae2e69a05c33dfc65f8.js.map 4.97 kB 2 [emitted] manifest index.html 509 bytes [emitted] Build complete. Tip: built files are meant to be served over an HTTP server. Opening index.html over file:// won't work.
这里多了dist目录,这里可以看到静态文件,后期就是将静态文件打包传到服务器上面,也就是网站根目录要发的包。
[root@jenkins-master devops-web-service-master]# lsbuild config dist index.html Jenkinsfile Jenkinsfile1 node_modules package.json package-lock.json README.md src static[root@jenkins-master devops-web-service-master]# cd dist/[root@jenkins-master dist]# lsindex.html static[root@jenkins-master dist]# ls static/css js
yarn
yarn,facebook取代npm的包管理工具,速度快。Yarn 缓存包,无需重复-。 并行-,安装速度快。
安装配置
npm install -g yarnyarn info
[root@jenkins-master devops-web-service-master]# yarn install[root@jenkins-master devops-web-service-master]# yarn buildyarn run v1.22.10$ node build/build.js?.building for production...(node:29002) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency(Use `node --trace-warnings ...` to show where the warning was created)(node:29002) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'find' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'head' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'set' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'test' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'to' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency(node:29002) Warning: Accessing non-existent property 'which' of module exports inside circular dependencyHash: c5df099009c25bc0dbcaVersion: webpack 3.12.0Time: 10486ms Asset Size Chunks Chunk Names static/js/app.2f2e5edd9af2c59aa514.js 11.5 kB 0 [emitted] app static/js/vendor.0aad2172a75b8ed4f46c.js 94.8 kB 1 [emitted] vendor static/js/manifest.2ae2e69a05c33dfc65f8.js 857 bytes 2 [emitted] manifest static/css/app.30790115300ab27614ce176899523b62.css 432 bytes 0 [emitted] appstatic/css/app.30790115300ab27614ce176899523b62.css.map 797 bytes [emitted] static/js/app.2f2e5edd9af2c59aa514.js.map 21.7 kB 0 [emitted] app static/js/vendor.0aad2172a75b8ed4f46c.js.map 494 kB 1 [emitted] vendor static/js/manifest.2ae2e69a05c33dfc65f8.js.map 4.97 kB 2 [emitted] manifest index.html 509 bytes [emitted] Build complete. Tip: built files are meant to be served over an HTTP server. Opening index.html over file:// won't work.Done in 12.46s.
def buildTools = ["web": "/usr/local/node-v14.16.1-linux-x64"]pipeline { agent { label "build" } options { skipDefaultCheckout true } stages { stage("GetCode"){ steps{ script{ println("-代码 --> 分支: ${env.branchName}") checkout([$class: 'GitSCM', branches: [[name: "${env.branchName}"]], extensions: [], userRemoteConfigs: [[credentialsId: '823b86fe-2c1b-466e-b0c3-66ae6991449d', url: "${gitHttpURL}"]]]) } } } stage("Build"){ steps { script { sh """ ${buildTools["web"]}/bin/npm install ${buildTools["web"]}/bin/npm run build """ } } } } post { always { script{ echo "always......" } } success { script { echo "success....." } } }}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~