Problem Importing and Using a Vue Component in a Plugin #11303
Unanswered
Carlos-Alexandre-Leutz
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm facing an issue when trying to import and use a Vue component within a plugin. My Vue 3 project has the following structure:
I work on a large system, and we have a unique situation within our system. We are updating the application to use new technologies.
We have a back-end built with Laravel 4.2 using Blade for the front-end.
Due to the size of the system, we are creating plugins with Vue 3 to develop parts of the front-end incrementally.
We cannot refactor everything at once because it has not been approved by management and would take too long. Therefore, we are making updates gradually.
Due to the peculiarities of our project, I encountered this problem.
In the code provided in my GitHub repository, I replicated our issue.
https://github.com/Carlos-Alexandre-Leutz/erro-no-vue-3
I have a component that I use within a plugin made with Vue 3, but I also need to use this same component in another Blade page separately.
With Vue 2, everything worked fine. However, in Vue 3, when I create a main.js for Component 2, everything stops working, and no error is thrown.
Below is a detailed description of what I'm doing.
In summary, I am building the application and calling the scripts within an index.html file that simulates my Blade.
When I build only Component 1, everything works.
When I build both Component 1 and Component 2, nothing works.
But there is an important detail:
When I register a child component in Component 2, the problem occurs. If I do not register it, I can use Component 1 and Component 2 normally.
However, the components in my application have several child components within their respective Component 2, so I need help to resolve this issue.
In
vue.config.js
, I have configured multiple entries forcomp_1
andcomp_2
:const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
productionSourceMap: false,
transpileDependencies: true,
filenameHashing: false,
outputDir: "./public/dist/vue-3",
pluginOptions: {
webpack: {
dir: ["./webpack"],
},
},
pages: {
comp_1: {
entry: "src/comp-1/main.js",
filename: "comp-1.html",
title: "comp-1",
},
// Comment on this section to see the project working
comp_2: {
entry: "src/comp-2/main.js",
filename: "comp-2.html",
title: "app_comp-2",
},
// Comment on this section to see the project working
},
});
Additionally, I have a component that I'm using both as a component within another plugin and as a standalone plugin:
When I uncomment the style section, the component stops working and shows no errors.
Questions
Comp2
not working when imported withinComp1
?Any help would be greatly appreciated! Thank you!
Additional Information
Relevant Code
https://github.com/Carlos-Alexandre-Leutz/erro-no-vue-3
With this detailed description, I hope to get help to resolve these issues. Thanks in advance for any guidance or solutions suggested.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions