Giter VIP home page Giter VIP logo

vue-sfc-vite's Introduction

Vue SFC Vite - A Vue 3 SFC Vite template

A package to create Vue 3 SFC Vite projects.
Inspired by VueSFCRollup
VueSFCRollup was a great package to create SFC Rollup projects. But after there deprecation of the package, we decided to create a similar package for Vite.

Used Vite/Library Mode configuration to create a single file component template for Vue 3 (Supports Vue 2 as well).

vue-sfc-vite is a CLI templating utility that scaffolds a minimal setup for compiling a Vue Single File Component ( SFC) - into a form ready to share via npm. It doesn't assume any particular flavor of CSS or docs generator, so you can use what you're already used to. It's the fastest way to produce npm-ready vue components!

Installation

Install globally

# Install globally (recommended)
npm install -g vue-sfc-vite
vue-sfc-vite

OR use via npx

# For immediate, no-install usage
npx vue-sfc-vite

Usage

# Fill in prompts

# Navigate to library folder
cd path/to/my-component-or-lib
npm install

## Create a SFC
vue-sfc-vite

[Note: visit here to get the installation guide for mono-repo using lerna]

SFC Options

  • Which version of Vue are you writing for?

    • Vue 3
    • Vue 2
  • Is this a single component or a library?

    • Single Component
  • What is the npm name of your component?

    • my-component
  • What is the kebab-case tag name for your component?

    • my-component
  • Will this component be written in JavaScript or TypeScript?

    • TypeScript
    • JavaScript
  • Enter a location to save the component files:

    • ./my-component

Add styles to your component

  • Visit my-component/src/assets/scss/my-component.scss and add your styles to the file.
    • In my-component.vue file, import the styles file as shown below:
      <style scoped lang="scss">
        @import "../assets/scss/<%= componentName %>.scss";
      </style>
      [Note: Importing styles in this way will make sure that the styles are scoped to the component. But if you import the styles in the <script lang="ts/js">...</script> tag of the SFC, then the styles might not work as expected. So, it's recommended to import the styles in the <style scoped lang="scss">...</style> tag of the SFC as shown above. Also, make sure that you have installed sass and sass-loader as dev dependencies. If not, then install them using the following command: npm install -D sass sass-loader. For more information, visit here.]

Features

  • ๐Ÿ“ฆ Single File Component - Create a single file component for Vue 3.
  • ๐Ÿ“ฆ Vue 2 Support - Create a single file component for Vue 2.
  • ๐Ÿ“ฆ Vue 3 Support - Create a single file component for Vue 3.
  • ๐Ÿ“ฆ Vue 3 Composition API - Create a single file component for Vue 3 with Composition API.
  • ๐Ÿ“ฆ Vue 3 Composition API + Vue 2 Support - Create a single file component for Vue 3 with Composition API and Vue 2 Support.

vue-sfc-vite's People

Contributors

afzalsabbir avatar arbs-23 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

tokunaga1

vue-sfc-vite's Issues

Build failed when using typescript.

When building a package with typescript getting this error.

Could not resolve entry module (src/components/index.js).
error during build:
Error: Could not resolve entry module (src/components/index.js).
    at error (file:///Users/raihanzaman/Desktop/TEQ_VP/reusable/vue3/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
    at ModuleLoader.loadEntryModule (file:///Users/raihanzaman/Desktop/TEQ_VP/reusable/vue3/node_modules/rollup/dist/es/shared/rollup.js:22175:20)
    at async Promise.all (index 0)

When looking at the vite.confog.ts file I found that

  lib: {
      // Could also be a dictionary or array of multiple entry points
      entry: resolve(__dirname, "src/components/index.js"),
      name: "BaseSidebar",
      // the proper extensions will be added
      fileName: (format) => `base-sidebar.${format}.js`,
    },

This should have been "src/components/index.ts" for anyone who has chosen typescript for making a library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.