1.0.5 โข Published 11 months ago
@kobonostudio/vite-plugin-webflow-bundler v1.0.5
๐ 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.jsonfor 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 devThen open:
http://localhost:3000/webflowYouโll get:
- โ CSS & JS loaders automatically generated
- ๐ Copy-paste buttons for Webflow custom code
- ๐ Automatic fallback between
localhostandjsDelivr
๐ Production Build
npm run buildThis 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
- Tries to load assets from
localhost - 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