2020年9月16日星期三

create a hello world by vite in linux docker

. make folder and create-vite-app.sh

mkdir vite
cd vite 
cat <<EOF >create-vite-app.sh
appname=$1
if [ -z $appname ]; then 
  echo "appname is not set, using default hello-vite."
  appname=hello-vite
else
  echo "appname=$appname"
fi  

npm init vite-app $appname
cd $appname
npm install 
npm run dev
EOF
chmod +x create-vite-app.sh

2. Create vite-app by  node:alpine  image

docker run -it --rm --name vite \
-w /app \
-v ~/vite:/app \
-p 3000:3000 \
lqwangxg/node:alpine \
./create-vite-app.sh vite-app-01

3.  Check to create the result.

ls 
create-vite-app.sh  vite-app-01
ls vite-app-01/
index.html         package-lock.json  public
node_modules       package.json       src

没有评论: