1. Download node. js
2. Using the wget command in Linux
wget https://nodejs.org/dist/latest-v6.x/node-v6.12.3-linux-x64.tar.gz
3. Unzip
TAR-XZVF node-v6. 12.3
4. Move node to the/usr/local directory
cd/usr/~/node-v6. 12.3-linux-x64./
5. Add Environment variables
Vim/etc/profile
6. Add a node path
node_home=/usr/local/node-v6.12.3-linux- x64Path= $PATH: $JAVA _home/bin:$NODE _home/binexport PATH Java_ HOME CLASSPATHnode_home
7. Reload the file
Source/etc/profile
8. Installing Webpack
NPM Install Webpack-g
9. Create a git code directory
10. Install git
Yum-y Install git
11. Pull Code
12. Go to the project folder, install dependencies
NPM Install --registry=https://registry.npm.taobao.org
13. Package here to execute
NPM Run Mydist
14. Create a production folder
CD/mkdir PRODUCTCD product# front-end project directory mkdir frontend CD frontend# project directory mkdir Mall-fe
15. Copy the dist file to the project directory
Mv/developer/git-repository/mall-fe/dist /product/frontend/mall-fe/dist
16. Write automated scripts to automate the publishing process above
Create and edit Vim fe-deploy.sh in the/developer directory
#GIT_HOME=/developer/git-repository/Dest_path=/product/frontend/#cd dirif[!-N" $" ]; Then Echo-E"Please enter name!"exit fiif[ $1="Mall-fe" ]; Then Echo-E"========enter mall-fe================"CD $GIT _home$1 ElseEcho-E"Not found!"exitfi#clear git dist echo-E"========clear Git dist================"RM-rf./Dist#git Echo-E"=======git Checkout master================"git checkout master echo-E"=======git pull================"git pull echo-E"=======NPM install================"NPM Install--registry=https://registry.npm.taobao.org#npm run mydist Echo-E"=======NPM Run mydist================"NPM Run Mydistif[-D"./dist" ]; Then #backup Destecho-E"================backup dist====================="RM-RF $DEST _path$1/back/Dist MV $DEST _path$1/dist $DEST _path$1/back/Dist #copy Echo-E"=======copy================"CP-R $GIT _home$1/dist $DEST _path$1#echo result Echo"======= Deploy success================" ElseEcho"======= Deploy error================"fi
Execution./fe-deploy.sh Mall-fe can be released automatically.
Linux front-end environment setup