Skip to content

About

A plugin to create a symlink to your custom build directory

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

⚡️ Vite Plugin Rolling Release npm license

A plugin to build viteJS app in a custom directory and then create a symlink at /dest/current pointing to your custom directory.

My usecase is the following :

  • I have a website build with Vite
  • My website is served by Caddy as a static site with file_server
  • When I update my website, if the build phase is long, Caddy could serve a mid-state site or completely crashed
  • My plugin allow me to build in a custom direct, then creating a symlink at dest/current, pointing to the new build directory once it's finish
  • This way, i'm 0️ down time.

Installation

npm install @aboulbox/vite-plugin-rolling-release

🔌 Usage

Add the plugin to your vite.config.js file.

import { defineConfig } from "vite";
import rollingrelease from "vite-plugin-rolling-release";

const buildDir = "dest/release_" + Date.now(); // Example
const outDir = import.meta.env.DEV ? "dist" : buildDir; // Don't need to change `outDir` for development but outDir must be the same as `buildDir` when building

export default defineConfig({
  plugins: [rollingrelease(buildDir)],
  outDir: outDir,
});

🧰 Options

buildDir

  • Type: string

  • Default: ''

    This is your build directory that dest/current will point to.

    ⚠️ buildDir must be relative to project root.

buildDir

  • Type: string

  • Default: ''

    This is your build directory that dest/current will point to.

    ⚠️ buildDir must be relative to project root.

buildDir

  • Type: string

  • Default: ''

    This is your build directory that dest/current will point to.

    ⚠️ buildDir must be relative to project root.

buildDir

  • Type: string

  • Default: ''

    This is your build directory that dest/current will point to.

    ⚠️ buildDir must be relative to project root.

💡 Ideas

  • Add an option to change the default symlink location (dest/current for now)
  • Add an option to clean releases and a option keep: X where X is the number of releases to keep.
  • Add an option for rolling release names (release_<gitsha> || <timestamp> || <random>)

🛠️ Development

  • Install dependencies:
npm install
  • Build the library:
npm run build

License

MIT LICENSE

About

A plugin to create a symlink to your custom build directory

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages