Reputation: 31
Are there any methods to compile some Component.vue
files to some javascript file? So that compiled js can be included in HTML and used with vue CDN.
For example, Lets' say we have some component Component.vue
, given below
<template>
<div class="demo">{{ msg }}</div>
</template>
<script>
export default {
data() {
return {
msg: "Jatin Garg",
};
},
};
</script>
<style scoped>
.demo {
color: blue;
}
</style>
Now we want to include the compiled Component.js in below HTML file.
<html lang="en">
<head>
<script src="/path/to/Component.js"></script>
<script src="vue@next"></script>
<body>
<div id="app">
<component></component>
</div>
</body>
<script>
const app = Vue.createApp({});
app.component("component", Component);
app.mount("#app");
</script>
</head>
<body></body>
</html>
I know a library called vue3-sfc-loader
that does a similar thing. But rather using ".js" file it directly takes the Component.vue
file and compiles it.
Basically, I want to compile the .vue
file offline
Upvotes: 2
Views: 1788
Reputation: 141
The point is that you need to convert your file, not compile it. So you can to find a script that could do this, or create it by yourself.
Here is the answer to the similar question with a suitable script.
Upvotes: 0