All Projects → privatenumber → vue-frag-plugin

privatenumber / vue-frag-plugin

Licence: MIT license
Webpack/Rollup/Vite plugin to add multiple root-node support to Vue 2 SFCs

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vue-frag-plugin

electron-template
Electron multiwindow mode template
Stars: ✭ 65 (+75.68%)
Mutual labels:  rollup, vite
unplugin
Unified plugin system for Vite, Rollup, Webpack, and more
Stars: ✭ 998 (+2597.3%)
Mutual labels:  rollup, vite
howdyjs
一个包含Javascript插件、Vue3组件、Vue3指令的工具库
Stars: ✭ 77 (+108.11%)
Mutual labels:  rollup, vite
Workflow
一个工作流平台
Stars: ✭ 1,888 (+5002.7%)
Mutual labels:  rollup, vite
vitext
The Next.js like React framework for better User & Developer experience!
Stars: ✭ 376 (+916.22%)
Mutual labels:  rollup, vite
electron-vue-next
A starter template for using vue-next with the electron.
Stars: ✭ 189 (+410.81%)
Mutual labels:  rollup, vite
aria-vue
Testing tools for Vue components
Stars: ✭ 21 (-43.24%)
Mutual labels:  rollup, vite
vite-svg
Use SVG files as Vue components with Vite
Stars: ✭ 98 (+164.86%)
Mutual labels:  vite
rakkasjs
Lightning fast Next.js alternative powered by Vite
Stars: ✭ 527 (+1324.32%)
Mutual labels:  vite
vite-primevue-starter
VUE 3 Starter project for using primevue 3 with Vite 2 - Pages, Layouts, Validation
Stars: ✭ 37 (+0%)
Mutual labels:  vite
reactjs-vite-tailwindcss-boilerplate
ReactJS + Vite boilerplate to be used with Tailwindcss.
Stars: ✭ 103 (+178.38%)
Mutual labels:  vite
admin-antd-vue
Vue3.x + Ant Design Admin template (vite/webpack)
Stars: ✭ 111 (+200%)
Mutual labels:  vite
react-component-lib
Boilerplate repo for creating npm packages with React components written in TypeScript and using styled-components
Stars: ✭ 69 (+86.49%)
Mutual labels:  rollup
magic-scroll
Apple Magic Mouse scrolling effect for normal mouses
Stars: ✭ 43 (+16.22%)
Mutual labels:  rollup
rollup-jest-boilerplate
🎉 Full featured boilerplate for building JavaScript libraries the modern way
Stars: ✭ 81 (+118.92%)
Mutual labels:  rollup
zero
📦 A zero config scripts library
Stars: ✭ 17 (-54.05%)
Mutual labels:  rollup
vue2-timeago
🙌 A vue component used to format date with time ago statement. 💬
Stars: ✭ 76 (+105.41%)
Mutual labels:  vite
tov-template
vite + vue3 + ts 开箱即用现代开发模板
Stars: ✭ 251 (+578.38%)
Mutual labels:  vite
vitesome
A simple opinionated Vue3 Starter Template with Vite.js
Stars: ✭ 124 (+235.14%)
Mutual labels:  vite
element-shuang
🎉基于 Vue3、element-plus、vite封装的后台管理系统模板,https://shuangda1018.github.io/element-shuang/#/table
Stars: ✭ 37 (+0%)
Mutual labels:  vite

vue-frag-plugin

Webpack/Rollup/Vite plugin to use multiple root nodes in Vue 2 Single-file Components (SFCs). Powered by vue-frag.

<template>
    <!-- No wrapping fragment! -->
    <span>
        Hello
    </span>
    <span>
        Multiple root nodes
    </span>
</template>

Support this project by ⭐️ starring and sharing it. Follow me to see what other cool projects I'm working on! ❤️

🚀 Install

npm i -D vue-frag-plugin vue-frag

🙋‍♂️ Why?

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.

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.

🚦 Quick setup

Webpack

Add vue-frag-plugin/loader before vue-loader in webpack.config.js.

Example webpack.config.js
   module.exports = {
     ...,

     module: {
       rules: [
         ...,

         // Update the vue-loader rule to insert `vue-frag-plugin/loader` before it
         {
           test: /\.vue$/,
-          loader: 'vue-loader',
+          use: [
+            'vue-loader',
+            'vue-frag-plugin/loader'
+          ]
         }
       ]
     }
   }

Rollup / Vite

  1. Import vueFrag from vue-frag-plugin
  2. Add it to plugins before the Vue plugin in rollup.config.js or vite.config.js
Example rollup.config.js
  import { definePlugin } from 'rollup
  import vue from 'rollup-plugin-vue'
+ import { vueFrag } from 'vue-frag-plugin'

 export default definePlugin({
   ...,

   plugins: [
+    vueFrag(), // Important this goes before `vue()`
     vue()
   ],

   ...
 })
Example vite.config.js
  import { definePlugin } from 'vite'
  import { createVuePlugin } from 'vite-plugin-vue2'
+ import { vueFrag } from 'vue-frag-plugin'

 export default definePlugin({
   ...,

   plugins: [
+    vueFrag(), // Important this goes before `createVuePlugin()`
     createVuePlugin()
   ],

   ...
 })

💞 Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].