Windows下,使用bat批量依次执行打包命令

@echo off

REM 生成的文件存放的目录
set fromPosition=".\dist\production"
REM 生成的文件的入口文件所存放的目录
set toPosition=".\dist\production\_uploadFile"

set lastIndex=1
set projectName0=common
set projectName1=gansu

for /L %%i in (0,1,%lastIndex%) do (

  for /F "usebackq delims==. tokens=1-3" %%J IN (`set projectName%%i`) do (

    REM 打包
    call npm run build:%%K:production

    REM 清理
    del /Q "%toPosition%\%%K\*.*"
    rmdir /Q "%toPosition%\%%K"

    REM REM 生成
    mkdir "%toPosition%/%%K"
    copy /y "%fromPosition%\%%K\index.html" "%toPosition%\%%K\index.html"
  )

)

pause

你可能感兴趣的:(bat)