unplugin-vue-script-name
v0.1.5
Published
Support <script name> for Vue script setup
Downloads
1
Readme
unplugin-vue-script-name
Support <script name>
for Vue script setup.
Install
npm i -D unplugin-vue-script-name
// vite.config.ts
import scriptName from "unplugin-vue-script-name/vite";
export default defineConfig({
plugins: [
scriptName({
/* options */
})
]
});
Example: playground/
// rollup.config.js
import scriptName from "unplugin-vue-script-name/rollup";
export default {
plugins: [
scriptName({
/* options */
})
]
};
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require("unplugin-vue-script-name/webpack").default({
/* options */
})
]
};
// nuxt.config.js
export default {
buildModules: [
[
"unplugin-vue-script-name/nuxt",
{
/* options */
}
]
]
};
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require("unplugin-vue-script-name/webpack").default({
/* options */
})
]
}
};
How It Works
<!-- MyComponent.vue -->
<script setup lang="ts" name="MyComponent">
defineProps({
title: { type: String }
});
</script>
<template>
<h1>{{title}}</h1>
</template>
<!-- Will be transformed to -->
<script>
export default { name: "MyComponent" };
</script>
<script setup lang="ts">
defineProps({
title: { type: String }
});
</script>
<template>
<h1>{{title}}</h1>
</template>