0.1.5 • Published 2 years ago

unplugin-vue-script-name v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

unplugin-vue-script-name

NPM version

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>
0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago