ERROR Error: Cannot call .tap() on a plugin that has not yet been defined. Call plugin('preload').use(<Plugin>) first.
时间: 2024-02-29 07:32:28 浏览: 222
gongetidu.zip_site:www.pudn.com_共轭梯度_对称矩阵
这个错误的原因是在调用.tap()方法之前没有先定义插件。根据提供的解决办法,你可以在vue.config.js文件中添加以下代码来解决这个问题:
module.exports = {
chainWebpack(config) {
config.plugin("preload").tap(() => [
{
rel: "preload",
fileBlacklist: [/\.(?:map|hot-update)\.(?:js|css)$/, /runtime\..*\.js$/],
include: "initial",
},
]);
config.plugin("preload-index").tap(() => [
{
rel: "preload",
fileBlacklist: [/\.(?:map|hot-update)\.(?:js|css)$/, /runtime\..*\.js$/],
include: "initial",
},
]);
config.plugin("preload-qr").tap(() => [
{
rel: "preload",
fileBlacklist: [/\.(?:map|hot-update)\.(?:js|css)$/, /runtime\..*\.js$/],
include: "initial",
},
]);
},
};
以上代码会在webpack配置中定义三个插件,并在调用.tap()方法之前先定义了这些插件,从而解决了错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [Vue Cli 配置多入口报错解决办法 Cannot call .tap() on a plugin that has not yet been defined](https://blog.csdn.net/qq_40259641/article/details/124730930)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文