feat: add language: 'svelte' with dedicated class regexes - #42
Merged
Conversation
SUPPORTTED_FILES already listed .svelte, but the plugin only had vue/react/blade
language options. Add Svelte-aware regexes that transform quoted UseClassy
modifiers while preserving native class:name={cond} directives, and wire
language through the plugin, CLI, and init helper.
Co-authored-by: Jeremy Butler <jrmybtlr@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
useclassy-com | 92dd32a | Commit Preview URL Branch Preview URL |
Jul 20 2026, 10:06 PM |
Add demos/svelte as a Vite + Svelte 5 + Tailwind v4 smoke app using language: 'svelte', with UseClassy variants alongside a native class directive so the coexistence path is exercised. Co-authored-by: Jeremy Butler <jrmybtlr@users.noreply.github.com>
jrmybtlr
marked this pull request as ready for review
July 17, 2026 21:42
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class Svelte support to the UseClassy Vite plugin by introducing Svelte-specific class attribute regexes and exposing language: 'svelte' across the public API, CLI init flow, docs, and demos.
Changes:
- Add
SVELTE_CLASS_REGEX/SVELTE_CLASS_MODIFIER_REGEXand wirelanguage: 'svelte'through the plugin + type definitions. - Extend init/CLI/docs to accept
--language svelteand document correct Vite plugin ordering for Svelte. - Add a new
demos/sveltesmoke demo and update the Vue demo UI to include Svelte alongside existing framework selections.
Reviewed changes
Copilot reviewed 29 out of 33 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/todo.md | Updates internal tracking notes related to framework selection sync. |
| src/types.d.ts | Extends ClassyOptions.language union to include 'svelte'. |
| src/init-setup.ts | Adds 'svelte' to INIT_LANGUAGES for init flows. |
| src/cli.ts | Updates CLI help text to include `--language ... |
| src/core.ts | Introduces Svelte-specific class / modifier regex exports. |
| src/index.ts | Wires Svelte regex selection via language: 'svelte' in the Vite plugin. |
| src/tests/init-setup.test.ts | Adds init test coverage for Tailwind VS Code classAttributes behavior with Svelte. |
| src/tests/index.test.ts | Adds plugin-level test ensuring Svelte language path is exercised. |
| src/tests/core.test.ts | Adds core behavior tests for Svelte modifiers + native directive preservation. |
| README.md | Documents Svelte usage and init command; updates language option references. |
| package.json | Adds svelte to package keywords. |
| pnpm-lock.yaml | Adds lock entries for the new Svelte demo and Vue demo icon deps; updates related dependency graph. |
| demos/vue/package.json | Adds Nuxt Icon + icon collection dependencies for framework icons in the demo UI. |
| demos/vue/nuxt.config.ts | Enables @nuxt/icon and configures server-bundled icon collection. |
| demos/vue/app/components/SegmentedControl.vue | Enhances segmented control options to support optional icons. |
| demos/vue/app/components/ClassExample.vue | Adds Svelte to demo formats and drives format via v-model + icons. |
| demos/vue/app/app.vue | Lifts shared demo format state and synchronizes hero/init/manual snippets. |
| demos/svelte/package.json | Adds a new Svelte demo package (Vite + Svelte + Tailwind + TS). |
| demos/svelte/vite.config.ts | Configures demo plugin ordering: UseClassy before Svelte compiler; sets port 3002. |
| demos/svelte/index.html | Adds the demo HTML entrypoint. |
| demos/svelte/svelte.config.js | Adds Svelte preprocess config. |
| demos/svelte/tsconfig.json | Adds TS project references for app/node configs. |
| demos/svelte/tsconfig.app.json | Adds app TS config extending @tsconfig/svelte. |
| demos/svelte/tsconfig.node.json | Adds node TS config for Vite/Svelte config files. |
| demos/svelte/.gitignore | Ignores demo build outputs and .classy/ generated manifest directory. |
| demos/svelte/public/vite.svg | Adds the demo favicon asset. |
| demos/svelte/src/vite-env.d.ts | Adds Svelte + Vite ambient type references. |
| demos/svelte/src/main.ts | Bootstraps Svelte app mount + Tailwind CSS import. |
| demos/svelte/src/main.css | Adds Tailwind import + @source pointing at the UseClassy manifest. |
| demos/svelte/src/App.svelte | Demo component showing quoted UseClassy modifiers + preserved native directives. |
| demos/svelte/README.md | Documents how to run the Svelte demo. |
| .cursor/rules/useclassy-plugin.mdc | Updates Cursor rules doc to include Svelte support details. |
| .cursor/rules/file-processing.mdc | Updates file-processing rules doc to include .svelte. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Updated @vitejs/plugin-react to version 6.0.3 in React demo. - Updated @sveltejs/vite-plugin-svelte to version 7.2.0 and svelte to version 5.46.4 in Svelte demo. - Improved logging in setupLaravelServiceProvider to check for the presence of the useclassy/laravel package and adjust messages accordingly. - Added tests to verify logging behavior based on package installation status.
…ing class attribute merging - Added `stripViteQuery` function to remove query and hash suffixes from file paths, aiding in accurate extension checks during HMR. - Updated `shouldProcessFile` to utilize `stripViteQuery` for better handling of file paths with Vite-specific queries. - Introduced tests for `stripViteQuery` and enhanced existing tests to cover new processing logic for class attributes.
…DATA sections - Enhanced `mergeClassAttributes` to correctly skip merging class attributes within HTML comments and CDATA sections that contain '>'. - Added a test case to verify that class attributes are not merged inside HTML comments, ensuring expected behavior in edge cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.sveltewas already inSUPPORTED_FILES, but there was nolanguage: 'svelte'option and no Svelte-specific regexes (Vue’s regexes include a:classlookahead that doesn’t apply to Svelte).This PR adds first-class Svelte support:
SVELTE_CLASS_REGEX/SVELTE_CLASS_MODIFIER_REGEXincore.tsclass:hover="...")class:active={cond}, shorthandclass:active):classbinding lookaheadlanguage: 'svelte'onClassyOptions, wired in the Vite plugin--language sveltedemos/svelte— Vite + Svelte 5 + Tailwind v4 smoke demo (mirrorsdemos/react), port 3002Usage
Place the plugin before
@sveltejs/vite-plugin-svelteso modifiers are rewritten before the Svelte compiler runs.Test plan
npm test— 184 passednpm run build(library) — succeedspnpm --filter svelte-demo build— succeeds; manifest has hover/md variants; nativeclass:scale-110={pressed}preserved in compiled output:3002and serves transformedApp.svelte