Vue?FileManagerPlugin?報(bào)錯(cuò)問(wèn)題及解決
Vue FileManagerPlugin 報(bào)錯(cuò)
項(xiàng)目場(chǎng)景
vue build時(shí)想直接打包輸出成zip
問(wèn)題描述
按照如下官方文檔內(nèi)寫(xiě)法, 提示出
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)變了!
解決方案
好了既然知道問(wèn)題,解決方案有兩種
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` }
]
}
}
}])
}以上配置,可以解決以下問(wèn)題
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)文章
elementui時(shí)間/日期選擇器選擇禁用當(dāng)前之前(之后)時(shí)間代碼實(shí)例
當(dāng)我們?cè)谶M(jìn)行網(wǎng)頁(yè)開(kāi)發(fā)時(shí),通常需要用到一些日期組件來(lái)方便用戶選擇時(shí)間,其中element日期組件是一個(gè)非常好用的工具,這篇文章主要給大家介紹了關(guān)于elementui時(shí)間/日期選擇器選擇禁用當(dāng)前之前(之后)時(shí)間的相關(guān)資料,需要的朋友可以參考下2024-02-02
一步步帶你用vite簡(jiǎn)單搭建ts+vue3全家桶
Vue3與TS的聯(lián)合是大趨勢(shì),下面這篇文章主要給大家介紹了關(guān)于用vite簡(jiǎn)單搭建ts+vue3全家桶的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07
VUE中的export default和export使用方法解析
export default和export都能導(dǎo)出一個(gè)模塊里面的常量,函數(shù),文件,模塊等,在其它文件或模塊中通過(guò)import來(lái)導(dǎo)入常量,函數(shù),文件或模塊。但是,在一個(gè)文件或模塊中export,import可以有多個(gè),export default卻只能有一個(gè)。2022-12-12
前端VUE雙語(yǔ)實(shí)現(xiàn)方案詳細(xì)教程
在項(xiàng)目需求中我們會(huì)遇到國(guó)際化的中英文切換,這篇文章主要給大家介紹了關(guān)于前端VUE雙語(yǔ)實(shí)現(xiàn)方案的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-08-08
Vue-cli3項(xiàng)目引入Typescript的實(shí)現(xiàn)方法
這篇文章主要介紹了Vue-cli3項(xiàng)目引入Typescript的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
Vuex(多組件數(shù)據(jù)共享的Vue插件)搭建與使用
Vuex是實(shí)現(xiàn)組件全局狀態(tài)(數(shù)據(jù))管理的一種機(jī)制,可以方便的實(shí)現(xiàn)組件之間數(shù)據(jù)的共享,數(shù)據(jù)緩存等等,下面這篇文章主要給大家介紹了關(guān)于Vuex(多組件數(shù)據(jù)共享的Vue插件)搭建與使用的相關(guān)資料,需要的朋友可以參考下2022-10-10
vue+element下日期組件momentjs轉(zhuǎn)換賦值問(wèn)題解決
這篇文章主要介紹了vue+element下日期組件momentjs轉(zhuǎn)換賦值問(wèn)題,記錄下使用momentjs轉(zhuǎn)換日期字符串賦值給element的日期組件報(bào)錯(cuò)問(wèn)題,需要的朋友可以參考下2024-02-02

