After npm run build, the dist file is automatically compressed into a ZIP file

The dist file must be compressed into a zip package after each npm run build of the project, and the filemanager-webpack-plugin plug-in can be used to achieve automatic compression

Install the plugin first
npm install filemanager-webpack-plugin --save-dev

vue2.x find module.exports in build/webpack.base.config.js. Then add in plugins

const FileManagerPlugin = require('filemanager-webpack-plugin')

new FileManagerPlugin({  //初始化 filemanager-webpack-plugin 插件实例
	onEnd: {
	     delete: [   //首先需要删除项目根目录下的dist.zip
	         './projectName.zip',
	     ],
	     archive: [ //然后我们选择dist文件夹将之打包成dist.zip并放在根目录
	         {source: './dist', destination: './projectName.zip'},   
	     ]
	 }
})

vuecli3.x add under vue.config.js

const FileManagerPlugin = require('filemanager-webpack-plugin')

module.exports = {
    configureWebpack: {  //webpack的相关配置在这里
        plugins: [
            new FileManagerPlugin({  //初始化 filemanager-webpack-plugin 插件实例
                onEnd: {
                    delete: [   //首先需要删除项目根目录下的dist.zip
                        './projectName.zip',
                    ],
                    archive: [ //然后我们选择dist文件夹将之打包成dist.zip并放在根目录
                        {source: './dist', destination: './projectName.zip'},   
                    ]
                }
            })
        ]
    }
}

Guess you like

Origin blog.csdn.net/weixin_43968658/article/details/102949470