{"id":16347532,"url":"https://github.com/privatenumber/vue-frag-plugin","last_synced_at":"2025-03-21T00:30:21.310Z","repository":{"id":37622589,"uuid":"423663964","full_name":"privatenumber/vue-frag-plugin","owner":"privatenumber","description":"Webpack/Rollup/Vite plugin to add multiple root-node support to Vue 2 SFCs","archived":false,"fork":false,"pushed_at":"2022-01-13T13:07:04.000Z","size":139,"stargazers_count":43,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-17T18:53:51.464Z","etag":null,"topics":["rollup","vite","vue","vue-frag","webpack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/privatenumber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-02T01:00:42.000Z","updated_at":"2024-11-22T07:24:25.000Z","dependencies_parsed_at":"2022-08-19T03:51:21.405Z","dependency_job_id":null,"html_url":"https://github.com/privatenumber/vue-frag-plugin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-frag-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-frag-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-frag-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-frag-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/vue-frag-plugin/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717070,"owners_count":20498279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rollup","vite","vue","vue-frag","webpack"],"created_at":"2024-10-11T00:43:24.465Z","updated_at":"2025-03-21T00:30:20.608Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-frag-plugin \u003ca href=\"https://npm.im/vue-frag-plugin\"\u003e\u003cimg src=\"https://badgen.net/npm/v/vue-frag-plugin\"\u003e\u003c/a\u003e\n\nWebpack/Rollup/Vite plugin to use multiple root nodes in Vue 2 [Single-file Components (SFCs)](https://vuejs.org/v2/guide/single-file-components.html). Powered by [`vue-frag`](https://github.com/privatenumber/vue-frag).\n\n\n```vue\n\u003ctemplate\u003e\n    \u003c!-- No wrapping fragment! --\u003e\n    \u003cspan\u003e\n        Hello\n    \u003c/span\u003e\n    \u003cspan\u003e\n        Multiple root nodes\n    \u003c/span\u003e\n\u003c/template\u003e\n```\n\n\u003csub\u003eSupport this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️\u003c/sub\u003e\n\n## 🚀 Install\n```sh\nnpm i -D vue-frag-plugin vue-frag\n```\n\n## 🙋‍♂️ Why?\n[`vue-frag`](https://github.com/privatenumber/vue-frag) is a directive that lets you use Fragments in Vue.js 2 components, but you have to manually register it and insert it as the root node.\n\n`vue-frag-plugin` is a build-time plugin that automates this process, injecting vue-frag where necessary. You will be able to use multiple root nodes seamlessly in your SFCs, bringing the developer experience much closer to Vue 3.\n\n## 🚦 Quick setup\n\n### Webpack\nAdd `vue-frag-plugin/loader` before `vue-loader` in `webpack.config.js`.\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample \u003ccode\u003ewebpack.config.js\u003c/code\u003e\u003c/summary\u003e\n  \u003cbr\u003e\n\n```diff\n   module.exports = {\n     ...,\n\n     module: {\n       rules: [\n         ...,\n\n         // Update the vue-loader rule to insert `vue-frag-plugin/loader` before it\n         {\n           test: /\\.vue$/,\n-          loader: 'vue-loader',\n+          use: [\n+            'vue-loader',\n+            'vue-frag-plugin/loader'\n+          ]\n         }\n       ]\n     }\n   }\n```\n\u003c/details\u003e\n\n\n### Rollup / Vite\n1. Import `vueFrag` from `vue-frag-plugin`\n2. Add it to `plugins` before the Vue plugin in `rollup.config.js` or `vite.config.js`\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample \u003ccode\u003erollup.config.js\u003c/code\u003e\u003c/summary\u003e\n  \u003cbr\u003e\n\n```diff\n  import { definePlugin } from 'rollup\n  import vue from 'rollup-plugin-vue'\n+ import { vueFrag } from 'vue-frag-plugin'\n\n export default definePlugin({\n   ...,\n\n   plugins: [\n+    vueFrag(), // Important this goes before `vue()`\n     vue()\n   ],\n\n   ...\n })\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample \u003ccode\u003evite.config.js\u003c/code\u003e\u003c/summary\u003e\n  \u003cbr\u003e\n\n```diff\n  import { definePlugin } from 'vite'\n  import { createVuePlugin } from 'vite-plugin-vue2'\n+ import { vueFrag } from 'vue-frag-plugin'\n\n export default definePlugin({\n   ...,\n\n   plugins: [\n+    vueFrag(), // Important this goes before `createVuePlugin()`\n     createVuePlugin()\n   ],\n\n   ...\n })\n```\n\u003c/details\u003e\n\n## 💞 Related\n- [unplugin-vue2-script-setup](https://github.com/antfu/unplugin-vue2-script-setup) - Build-time plugin to use `\u003cscript setup\u003e` in Vue 2 SFC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fvue-frag-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fvue-frag-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fvue-frag-plugin/lists"}