Gathering detailed insights and metrics for @vitejs/plugin-vue2
Gathering detailed insights and metrics for @vitejs/plugin-vue2
Gathering detailed insights and metrics for @vitejs/plugin-vue2
Gathering detailed insights and metrics for @vitejs/plugin-vue2
npm install @vitejs/plugin-vue2
Typescript
Module System
Min. Node Version
Node Version
NPM Version
58.9
Supply Chain
91.2
Quality
89.6
Maintenance
50
Vulnerability
98.2
License
TypeScript (81.25%)
Vue (11.14%)
JavaScript (6.84%)
HTML (0.65%)
CSS (0.13%)
Total Downloads
18,751,694
Last Day
27,120
Last Week
252,541
Last Month
1,058,121
Last Year
11,324,872
555 Stars
65 Commits
48 Forks
10 Watching
1 Branches
38 Contributors
Latest Version
2.3.3
Package Id
@vitejs/plugin-vue2@2.3.3
Unpacked Size
112.89 kB
Size
29.60 kB
File Count
7
NPM Version
8.19.4
Node Version
16.20.2
Publised On
26 Nov 2024
Cumulative downloads
Total Downloads
Last day
-48.4%
27,120
Compared to previous day
Last week
-4.8%
252,541
Compared to previous week
Last month
-1.9%
1,058,121
Compared to previous month
Last year
67.7%
11,324,872
Compared to previous year
[!CAUTION] Vue 2 has reached EOL, and this project is no longer actively maintained.
Note: this plugin only works with Vue@^2.7.0.
1// vite.config.js 2import vue from '@vitejs/plugin-vue2' 3 4export default { 5 plugins: [vue()] 6}
1export interface Options { 2 include?: string | RegExp | (string | RegExp)[] 3 exclude?: string | RegExp | (string | RegExp)[] 4 5 isProduction?: boolean 6 7 // options to pass on to vue/compiler-sfc 8 script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins'>> 9 template?: Partial< 10 Pick< 11 SFCTemplateCompileOptions, 12 | 'compiler' 13 | 'compilerOptions' 14 | 'preprocessOptions' 15 | 'transpileOptions' 16 | 'transformAssetUrls' 17 | 'transformAssetUrlsOptions' 18 > 19 > 20 style?: Partial<Pick<SFCStyleCompileOptions, 'trim'>> 21}
When @vitejs/plugin-vue2
compiles the <template>
blocks in SFCs, it also converts any encountered asset URLs into ESM imports.
For example, the following template snippet:
1<img src="../image.png" />
Is the same as:
1<script setup> 2import _imports_0 from '../image.png' 3</script>
1<img :src="_imports_0" />
By default the following tag/attribute combinations are transformed, and can be configured using the template.transformAssetUrls
option.
1{ 2 video: ['src', 'poster'], 3 source: ['src'], 4 img: ['src'], 5 image: ['xlink:href', 'href'], 6 use: ['xlink:href', 'href'] 7}
Note that only attribute values that are static strings are transformed. Otherwise, you'd need to import the asset manually, e.g. import imgUrl from '../image.png'
.
vue/compiler-sfc
:1import vue from '@vitejs/plugin-vue2' 2 3export default { 4 plugins: [ 5 vue({ 6 template: { 7 compilerOptions: { 8 // ... 9 }, 10 transformAssetUrls: { 11 // ... 12 } 13 } 14 }) 15 ] 16}
1import vue from '@vitejs/plugin-vue2' 2 3const vueI18nPlugin = { 4 name: 'vue-i18n', 5 transform(code, id) { 6 if (!/vue&type=i18n/.test(id)) { 7 return 8 } 9 if (/\.ya?ml$/.test(id)) { 10 code = JSON.stringify(require('js-yaml').load(code.trim())) 11 } 12 return `export default Comp => { 13 Comp.i18n = ${code} 14 }` 15 } 16} 17 18export default { 19 plugins: [vue(), vueI18nPlugin] 20}
MIT
No vulnerabilities found.
No security vulnerabilities found.