Git Product home page Git Product logo

vite-lib-demo's Introduction

Vite "library-mode" Demo

This is a simple example of how to use Vite to build a component library without introducing a lot of extra junk. This example is adapted from this example in the Vite playground repo.

Installation

npm install

Usage

# Run the dev server
npm run dev
# Generate output
npm run build

This example takes advantage of Vite's "library mode" feature: https://vitejs.dev/guide/build.html#library-mode. As configured, this project can do the following:

  • vue dependency is externalized, not included in the build (and handled as a window.Vue global for the UMD build).
  • Single-file Components are pre-compiled into render functions
  • LESS imports are processed and resulting CSS is exported into a separate .css file
  • Builds the component library in both ES Module and UMD versions; the latter supports CommonsJS, AMD, and IIFE usage.
  • Builds a stand-alone index.html file for demo purposes that is not included in the exported library builds.

File structure:

.
├── README.md
├── dist
│   ├── index.html
│   ├── sd-components.es.js
│   ├── sd-components.umd.js
│   └── style.css
├── index.dist.html
├── index.html
├── package-lock.json
├── package.json
├── src
│   ├── Demo.vue
│   ├── components
│   │   ├── Button.vue
│   │   └── Icon.vue
│   ├── icons.js
│   ├── main.js
│   ├── mediawiki.mixins.less
│   └── variables.less
└── vite.config.js

vite-lib-demo's People

Contributors

egardner avatar

Stargazers

James Tsang avatar Ari Palo avatar

Watchers

 avatar James Cloos avatar

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.