webpack配置打包zip

1. 插件安装

npm install filemanager-webpack-plugin --save-dev

2. webpack配置

vue.config.js文件

const FileManagerPlugin = require('filemanager-webpack-plugin')
   configureWebpack: config => {
      if (process.argv[6]) {  // 有条件的打包zip文件
        config.plugins.push(
          new FileManagerPlugin({
            events: {
              onEnd: {
                delete: ['./dist/admin.zip'],
                // mkdir: ['/path/to/directory/', '/another/directory/'],
                archive: [
                  { source: './dist', destination: './dist/admin.zip' },
                  // {
                  //   source: '/path/fromfile.txt',
                  //   destination: '/path/to.tar.gz',
                  //   format: 'tar',
                  //   options: {
                  //     gzip: true,
                  //     gzipOptions: {
                  //       level: 1,
                  //     },
                  //     globOptions: {
                  //       nomount: true,
                  //     },
                  //   },
                  // },
                ],
              },
            },
          }),
        )
      }
    }
  1. package.json配置

"build:zip": "vue-cli-service build --mode production --gulp zip",

你可能感兴趣的:(webpack配置打包zip)