{"_id":"@94ai/vite-plugin-vue2","_rev":"2-93bd5bbb9f8717c93895b9240a2a1052","name":"@94ai/vite-plugin-vue2","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@94ai/vite-plugin-vue2","version":"1.0.0","license":"MIT","author":{"name":"zoujiahe"},"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"scripts":{"dev":"unbuild --stub","build":"unbuild && esno scripts/patchCJS.ts","test":"vitest run","release":"node scripts/release.js","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s"},"engines":{"node":"^14.18.0 || >= 16.0.0"},"repository":{"type":"git","url":"https://gitee.com/xccjh/xccjh-vite-plugin-vue2.git"},"bugs":{"url":"https://gitee.com/xccjh/xccjh-vite-plugin-vue2/issues"},"homepage":"https://gitee.com/xccjh/xccjh-vite-plugin-vue2","peerDependencies":{"vite":"^3.0.0 || ^4.0.0","vue":"^2.7.0-0"},"devDependencies":{"@types/fs-extra":"^9.0.13","conventional-changelog-cli":"^2.2.2","debug":"^4.3.4","enquirer":"^2.3.6","esno":"^0.16.3","execa":"^4.1.0","fs-extra":"^10.1.0","hash-sum":"^2.0.0","minimist":"^1.2.6","picocolors":"^1.0.0","prettier":"^2.7.1","puppeteer":"^14.4.0","rollup":"^2.75.6","semver":"^7.3.7","slash":"^3.0.0","source-map":"^0.6.1","unbuild":"^0.7.4","vite":"^3.0.0","vitest":"^0.15.1","vue":"^2.7.0-beta.8"},"gitHead":"b6b78dd82c9b260b6e443f1698afbb6f0816e828","description":"> Note: this plugin only works with Vue@^2.7.0. \r > @vitejs/plugin-vue2 not support config runtime helpers inject modify. \r > @94ai/vite-plugin-vue2 Expanded a configuration `normalizerCode` to config custom runtime helpers logic.","_id":"@94ai/vite-plugin-vue2@1.0.0","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-cFYqbju3M6Z6dMEpLtyj1Xw/OyUhLYNuJb5tZM7RoafMKQ922274d0yLtrmMIxzjbMQVYyVhgWNmjclfxFkFtA==","shasum":"85f498c4eeebca07fbd537849312d5b0537c7572","tarball":"https://registry.npmjs.org/@94ai/vite-plugin-vue2/-/vite-plugin-vue2-1.0.0.tgz","fileCount":6,"unpackedSize":79815,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5FPNhshL86aLpuRyqi9QtZf0Uc5iurmc1cXAXfkTl/gIhAJFP59TpmGVx8DSMuWl9PFKK+wPzfUE8J7pZ+kDL3lZT"}]},"_npmUser":{"name":"94ai","email":"zjh15018707394@gmail.com"},"directories":{},"maintainers":[{"name":"94ai","email":"zjh15018707394@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vite-plugin-vue2_1.0.0_1693828486720_0.15915073498473498"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-04T11:54:46.554Z","1.0.0":"2023-09-04T11:54:46.942Z","modified":"2024-05-24T09:11:34.066Z"},"maintainers":[{"email":"liuxiangxiang1992@gmail.com","name":"louislxx"},{"email":"zjh15018707394@gmail.com","name":"nfai"}],"description":"> Note: this plugin only works with Vue@^2.7.0. \r > @vitejs/plugin-vue2 not support config runtime helpers inject modify. \r > @94ai/vite-plugin-vue2 Expanded a configuration `normalizerCode` to config custom runtime helpers logic.","homepage":"https://gitee.com/xccjh/xccjh-vite-plugin-vue2","repository":{"type":"git","url":"https://gitee.com/xccjh/xccjh-vite-plugin-vue2.git"},"author":{"name":"zoujiahe"},"bugs":{"url":"https://gitee.com/xccjh/xccjh-vite-plugin-vue2/issues"},"license":"MIT","readme":"# @94ai/vite-plugin-vue2\r\n\r\n> Note: this plugin only works with Vue@^2.7.0. \r\n> @vitejs/plugin-vue2 not support config runtime helpers inject modify. \r\n> @94ai/vite-plugin-vue2 Expanded a configuration `normalizerCode` to config custom runtime helpers logic. \r\n\r\n```js\r\n// vite.config.js, replace @vitejs/plugin-vue2 to @94ai/vite-plugin-vue2\r\nimport vue from '@94ai/vite-plugin-vue2'\r\n\r\nexport default {\r\n  plugins: [vue({\r\n    normalizerCode: `\r\nimport { normalizeComponent } from '@94ai/runtime/helpers'\r\nexport default normalizeComponent`,\r\n    include: [/\\.vue$/, /\\.md$/, /\\.jsx$/, /\\.tsx$/], // other config same with @vitejs/plugin-vue2\r\n    // ...\r\n  })]\r\n}\r\n```\r\n\r\n## Options\r\n\r\n```ts\r\nexport interface Options {\r\n  include?: string | RegExp | (string | RegExp)[]\r\n  exclude?: string | RegExp | (string | RegExp)[]\r\n\r\n  isProduction?: boolean\r\n\r\n  // options to pass on to vue/compiler-sfc\r\n  script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins'>>\r\n  template?: Partial<\r\n    Pick<\r\n      SFCTemplateCompileOptions,\r\n      | 'compiler'\r\n      | 'compilerOptions'\r\n      | 'preprocessOptions'\r\n      | 'transpileOptions'\r\n      | 'transformAssetUrls'\r\n      | 'transformAssetUrlsOptions'\r\n    >\r\n  >\r\n  style?: Partial<Pick<SFCStyleCompileOptions, 'trim'>>\r\n  /**\r\n   * config custom runtime helpers logic\r\n   */\r\n  normalizerCode?: string;\r\n}\r\n```\r\n\r\n## Asset URL handling\r\n\r\nWhen `@94ai/vite-plugin-vue2` compiles the `<template>` blocks in SFCs, it also converts any encountered asset URLs into ESM imports.\r\n\r\nFor example, the following template snippet:\r\n\r\n```vue\r\n<img src=\"../image.png\" />\r\n```\r\n\r\nIs the same as:\r\n\r\n```vue\r\n<script setup>\r\nimport _imports_0 from '../image.png'\r\n</script>\r\n```\r\n\r\n```vue\r\n<img :src=\"_imports_0\" />\r\n```\r\n\r\nBy default the following tag/attribute combinations are transformed, and can be configured using the `template.transformAssetUrls` option.\r\n\r\n```js\r\n{\r\n  video: ['src', 'poster'],\r\n  source: ['src'],\r\n  img: ['src'],\r\n  image: ['xlink:href', 'href'],\r\n  use: ['xlink:href', 'href']\r\n}\r\n```\r\n\r\nNote 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'`.\r\n\r\n## Example for passing options to `vue/compiler-sfc`:\r\n\r\n```ts\r\nimport vue from '@94ai/vite-plugin-vue2'\r\n\r\nexport default {\r\n  plugins: [\r\n    vue({\r\n      template: {\r\n        compilerOptions: {\r\n          // ...\r\n        },\r\n        transformAssetUrls: {\r\n          // ...\r\n        }\r\n      }\r\n    })\r\n  ]\r\n}\r\n```\r\n\r\n## Example for transforming custom blocks\r\n\r\n```ts\r\nimport vue from '@94ai/vite-plugin-vue2'\r\n\r\nconst vueI18nPlugin = {\r\n  name: 'vue-i18n',\r\n  transform(code, id) {\r\n    if (!/vue&type=i18n/.test(id)) {\r\n      return\r\n    }\r\n    if (/\\.ya?ml$/.test(id)) {\r\n      code = JSON.stringify(require('js-yaml').load(code.trim()))\r\n    }\r\n    return `export default Comp => {\r\n      Comp.i18n = ${code}\r\n    }`\r\n  }\r\n}\r\n\r\nexport default {\r\n  plugins: [vue(), vueI18nPlugin]\r\n}\r\n```\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}