webpack filemanager-webpack-plugin 打多个zip时,出现循环打包情况

项目中用filemanager-webpack-plugin插件多次打zip会有问题,所以就有了在webpack 打包结束后,再执行打zip包操作的方案

package.json
 "scripts": {
    "build:prd": "node build/build.js --env=prd && node packageZip.js --env=prd"
  },
packageZip.js
const fs = require('fs')
const argv = require('yargs').argv // package依赖
const zipper = require('zip-local');  // package依赖

const dir = `${argv.env}/20211216`

fs.mkdir(dir, err => {
  if (err) {
    console.log(`目录${dir}创建失败`, err)
    return
  }
 zipper.sync.zip('./dist/h5').compress().save(`./${dir}/package.zip`)
})

你可能感兴趣的:(前端,webpack,前端,javascript)