webpack插件filemanager-webpack-plugin(将dist文件夹自动压缩成生成dist.zip压缩包)

目标

yarn  build:prod后生成的dist资源文件夹,自动打包成dist.zip压缩包

安装插件

[email protected]: The engine "node" is incompatible with this module. Expected version "^12.20.0 || ^14.13.1 || >=16.0.0".

windows更新Node版本

yarn add filemanager-webpack-plugin -D

npm i filemanager-webpack-plugin -D

cnpm i filemanager-webpack-plugin -D

配置使用

vue.config.js

const FileManagerPlugin = require('filemanager-webpack-plugin');
module.exports = {
   configureWebpack: config =>  {
    config.plugins.push(
      new FileManagerPlugin(
        {
          events: {
            onEnd: {
              delete: ['./dist.zip'],
              archive: [{
                source: path.join(__dirname, './dist'),
                destination: path.join(__dirname, './dist.zip')
              }]
            }
          }
        }
      )
    )
  },
}

你可能感兴趣的:(工程化,webpack)