webpack打包完成,復制,打包,移動,刪除已生成的文件插件


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

詳情請到 https://www.npmjs.com/ 一看究竟

 貼個我實際開發中用到的例子吧,所實現的功能就是 打包時 在項目中

1、自動創建 zip文件夾

2、將打包輸出的 dist 文件夾 放到 臨時文件夾tempzip下。 

3、將tempzip打包 放到 zip 文件夾下,供自己使用。

//打包
        config.plugins.push(new filemanager(
            {
                onEnd: {
                    //創建目錄
                    mkdir: ['./zip', './tempzip/' + zipName],
                    //復制文件到tempzip
                    copy: [{
                        source: './dist',
                        destination: './tempzip/' + zipName
                    },],
                    //打包temzip,輸出到zip文件夾下
                    archive: [{
                        source: './tempzip/',
                        destination: './zip/' + zipName + '.zip'
                    }],
                    //刪除tempzip
                    delete: [
                        './tempzip/'
                    ]
                }
            }
        ));

有幫助請點推薦哦,蟹蟹!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM