Gathering detailed insights and metrics for @94ai/vite-plugin-vue2
Gathering detailed insights and metrics for @94ai/vite-plugin-vue2
Gathering detailed insights and metrics for @94ai/vite-plugin-vue2
Gathering detailed insights and metrics for @94ai/vite-plugin-vue2
npm install @94ai/vite-plugin-vue2
Typescript
Module System
Min. Node Version
Node Version
NPM Version
55
Supply Chain
90.9
Quality
77.3
Maintenance
50
Vulnerability
98.2
License
Total Downloads
310
Last Day
1
Last Week
7
Last Month
18
Last Year
140
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
@94ai/vite-plugin-vue2@1.0.0
Unpacked Size
77.94 kB
Size
20.93 kB
File Count
6
NPM Version
8.19.3
Node Version
16.19.1
Published on
Sep 04, 2023
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
600%
7
Compared to previous week
Last Month
-40%
18
Compared to previous month
Last Year
-17.6%
140
Compared to previous year
Note: this plugin only works with Vue@^2.7.0. @vitejs/plugin-vue2 not support config runtime helpers inject modify. @94ai/vite-plugin-vue2 Expanded a configuration
normalizerCode
to config custom runtime helpers logic.
1// vite.config.js, replace @vitejs/plugin-vue2 to @94ai/vite-plugin-vue2 2import vue from '@94ai/vite-plugin-vue2' 3 4export default { 5 plugins: [vue({ 6 normalizerCode: ` 7import { normalizeComponent } from '@94ai/runtime/helpers' 8export default normalizeComponent`, 9 include: [/\.vue$/, /\.md$/, /\.jsx$/, /\.tsx$/], // other config same with @vitejs/plugin-vue2 10 // ... 11 })] 12}
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 /** 22 * config custom runtime helpers logic 23 */ 24 normalizerCode?: string; 25}
When @94ai/vite-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 '@94ai/vite-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 '@94ai/vite-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.