Code Monkey home page Code Monkey logo

vite-plugin-kss's Introduction

vite-plugin-kss

Plugin to integrate KSS (specifically kss-node) into the Vite bundling process.

Setup

Installation

npm i --save-dev vite-plugin-kss

Configuration

Add ViteKSS plugin to your vite.config.{js,ts} and configure it:

import { ViteKSS } from 'vite-plugin-kss'

export default {
  plugins: [
    ViteKSS({
      dev: {
        // base of the KSS output being available on the Vite dev server
        base: '/prototype/',

        // entry script file (for injection into KSS)
        entry: '/src/main.js',
      },

      kss: {
        // any of the kss-node options can go here
        // reference: https://github.com/kss-node/kss-node#using-the-command-line-tool
        // the important ones you should set are:
        // - source
        // - destination
      },
    }),
  ],
}

Usage

With the plugin configured, KSS generation is now done when running both vite build or vite dev/vite serve.

When doing a production build with vite build the plugin automatically collects all JS entrypoints and CSS assets, also outputs them to the configured KSS destination and includes them in the build configuration so they are rendered into the HTML output.

If a development server is running using vite dev/vite serve, KSS is available at localhost:5173/prototype/ (or the configured dev.base location). The plugin automatically injects the Vite client and entrypoint (configured in dev.entry) so HMR and all assets work properly.

License

This project is licensed under the MIT License

vite-plugin-kss's People

Contributors

dependabot[bot] avatar pixeldesu avatar

Watchers

 avatar  avatar

vite-plugin-kss's Issues

Rewrite "naive" asset fetching when running `vite build`

The initial release of this plugin contains a relatively naive assumption for the styleguide assets, as it specifically filters out only .js and .css files from the built bundle.

Instead, all referenced assets from the entrypoint JS file (which hopefully includes used images, fonts, whatever) should be included.

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.