Vue?FileManagerPlugin?報(bào)錯(cuò)問題及解決
Vue FileManagerPlugin 報(bào)錯(cuò)
項(xiàng)目場(chǎng)景
vue build時(shí)想直接打包輸出成zip
問題描述
按照如下官方文檔內(nèi)寫法, 提示出
Invalid actions object. FileManagerPlugin has been initialized using an actions object that does not match the API schema
const FileManagerPlugin = require('filemanager-webpack-plugin'); module.exports = { ... ... plugins: [ new FileManagerPlugin({ onEnd: { copy: [ { source: '/path/from', destination: '/path/to' }, { source: '/path/**/*.js', destination: '/path' }, { source: '/path/fromfile.txt', destination: '/path/tofile.txt' }, { source: '/path/**/*.{html,js}', destination: '/path/to' }, { source: '/path/{file1,file2}.js', destination: '/path/to' }, { source: '/path/file-[hash].js', destination: '/path/to' } ], move: [ { source: '/path/from', destination: '/path/to' }, { source: '/path/fromfile.txt', destination: '/path/tofile.txt' } ], delete: [ '/path/to/file.txt', '/path/to/directory/' ], mkdir: [ '/path/to/directory/', '/another/directory/' ], archive: [ { source: '/path/from', destination: '/path/to.zip' }, { source: '/path/**/*.js', destination: '/path/to.zip' }, { source: '/path/fromfile.txt', destination: '/path/to.zip' }, { source: '/path/fromfile.txt', destination: '/path/to.zip', format: 'tar' }, { source: '/path/fromfile.txt', destination: '/path/to.tar.gz', format: 'tar', options: { gzip: true, gzipOptions: { level: 1 }, globOptions: { nomount: true } } } ] } }) ], ... }
原因分析
直接去npm里去查文檔, 看到了這個(gè)??!!
結(jié)構(gòu)變了!
解決方案
好了既然知道問題,解決方案有兩種
1.用老版本~
npm i filemanager-webpack-plugin@2.0.5
2.用新版本
具體如何使用參考文檔~~
npm文檔地址:https://www.npmjs.com/package/filemanager-webpack-plugin/v/3.1.0
Vue配置filemanager-webpack-plugin報(bào)錯(cuò)
安裝包版本:"filemanager-webpack-plugin": "^7.0.0-beta.0",
正確配置方式
const FileManagerPlugin = require('filemanager-webpack-plugin') // 引入 const packageName = 'dist' chainWebpack(config) { config.plugin('fileManager') .use(FileManagerPlugin).tap(args => [{ events: { onEnd: { delete: [ // 首先需要?jiǎng)h除項(xiàng)目根目錄下的dist.zip `./${packageName}.zip` ], archive: [ // 選擇文件夾將之打包成xxx.zip并放在根目錄 { source: `./${packageName}`, destination: `./${packageName}.zip` } ] } } }]) }
以上配置,可以解決以下問題
1.TypeError: config.plugins.push is not a function
2. ERROR ValidationError: Invalid actions object. FileManagerPlugin has been initialized using an actions object that does not match the API schema.
- actions has an unknown property 'onEnd'. These properties are valid:
object { events?, runTasksInSeries?, context?, runOnceInWatchMode? }
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
antd?vue?表格rowSelection選擇框功能的使用方式
這篇文章主要介紹了antd?vue?表格rowSelection選擇框功能的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。2022-12-12vue 的點(diǎn)擊事件獲取當(dāng)前點(diǎn)擊的元素方法
今天小編就為大家分享一篇vue 的點(diǎn)擊事件獲取當(dāng)前點(diǎn)擊的元素方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-09-09vue里的axios如何獲取本地json數(shù)據(jù)
這篇文章主要介紹了vue里的axios如何獲取本地json數(shù)據(jù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08vue3基礎(chǔ)組件開發(fā)detePicker日期選擇組件示例
這篇文章主要為大家介紹了vue3基礎(chǔ)組件開發(fā)-detePicker(日期選擇組件)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03使用vue3-print-nb實(shí)現(xiàn)打印pdf分頁代碼示例
這篇文章主要介紹了使用vue3-print-nb實(shí)現(xiàn)打印pdf分頁的相關(guān)資料,這種方法不僅適用于Vue3項(xiàng)目,也可以在其他前端框架中實(shí)現(xiàn)類似的打印分頁功能,需要的朋友可以參考下2024-10-10ElementUI Tag組件實(shí)現(xiàn)多標(biāo)簽生成的方法示例
這篇文章主要介紹了ElementUI Tag組件實(shí)現(xiàn)多標(biāo)簽生成的方法示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07使用vue框架 Ajax獲取數(shù)據(jù)列表并用BootStrap顯示出來
這篇文章主要介紹了使用vue框架 Ajax獲取數(shù)據(jù)列表并用BootStrap顯示出來,需要的朋友可以參考下2017-04-04