1.0.5 โ€ข Published 11 months ago

@kobonostudio/vite-plugin-webflow-bundler v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

๐Ÿš€ vite-plugin-webflow-bundler

A Vite plugin that compiles and bundles your JavaScript and CSS files for seamless integration with Webflow, optimized for:

  • Local development (localhost)
  • Production delivery via GitHub CDN (jsDelivr)

โœจ Features

  • โšก Automatically generates CSS and JS loaders for Webflow
  • ๐Ÿ”„ Export files into dist/
  • ๐Ÿ“ฆ Creates a manifest.json for CDN version tracking
  • ๐Ÿงช Local interface at http://localhost:3000/webflow
  • ๐Ÿง  Smart fallback logic: localhost โ†’ CDN
  • ๐Ÿงน Automatic minification (individual files)

๐Ÿ“ฆ Installation

npm install --save-dev @kobonostudio/vite-plugin-webflow-bundler

โš™๏ธ Basic Setup

1. Add the plugin to vite.config.js

import { defineConfig } from 'vite'
import webflowBundlerPlugin from '@kobonostudio/vite-plugin-webflow-bundler'

export default defineConfig({
  plugins: [webflowBundlerPlugin()],
})

2. Create a starter.config.js file

export default {
  cdn: {
    baseUrl: 'https://cdn.jsdelivr.net/gh',
    user: 'your-github-user',
    repo: 'your-repo-name',
    branch: 'main',
    org: true, // or false for personal accounts
  },

  deploy: {
    mode: 'split', // 'none' | 'public-only' | 'split'
    publicRepo: 'my-webflow-project-prod',
    privateRepo: 'my-webflow-project',
    branch: 'main',
  },

  // (optional) custom order for CSS files
  cssOrder: [
    'reset.css',
    'variables.css',
    'layout.css',
    'components/button.css',
    'styles.css',
  ],
}

๐Ÿ“ Recommended Structure

your-project/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ”œโ”€โ”€ reset.css
โ”‚   โ”‚   โ”œโ”€โ”€ variables.css
โ”‚   โ”‚   โ”œโ”€โ”€ layout.css
โ”‚   โ”‚   โ””โ”€โ”€ styles.css
โ”‚   โ””โ”€โ”€ main.js
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ vite.config.js
โ”œโ”€โ”€ starter.config.js
โ””โ”€โ”€ ...

๐Ÿงช Local Development

npm run dev

Then open:

http://localhost:3000/webflow

Youโ€™ll get:

  • โœ… CSS & JS loaders automatically generated
  • ๐Ÿ“‹ Copy-paste buttons for Webflow custom code
  • ๐Ÿ” Automatic fallback between localhost and jsDelivr

๐Ÿš€ Production Build

npm run build

This will:

  • ๐Ÿ”ง Minify and copy CSS and JS files into dist/
  • ๐Ÿ“ฆ Generate a manifest.json
  • ๐Ÿง  Inject loader snippets into dist/index.html

๐Ÿ”Ž Output Structure

dist/
โ”œโ”€โ”€ css/
โ”‚   โ”œโ”€โ”€ reset.css
โ”‚   โ”œโ”€โ”€ variables.css
โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ””โ”€โ”€ main.css
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ main.js
โ”œโ”€โ”€ manifest.json
โ””โ”€โ”€ index.html (with injected loaders)

๐Ÿง  How It Works

  1. Tries to load assets from localhost
  2. If that fails (e.g. in Webflow), it falls back to GitHub CDN (via jsDelivr)

๐Ÿง  Author

Made with โค๏ธ by Pierre Lovenfosse

๐Ÿ“„ License

MIT โ€” ยฉ Pierre Lovenfosse

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago