[v4] How I updated my v3 plugin to v4 #16186
jthayworth
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This has been a pretty hot topic for plugin creators since the release of v4. So I just wanted to put something on here about how I migrated a v3 plugin to v4 without the need of
@plugindirective in hopes that it might help some of you that have the same needs I did. This very well could not be the best way to do it, but it works for me.File Structure
index.cssThis is the entry point for the plugin. The
utilities.components.baseandutilities.components.modifierwill ensure your css is applied in the correct order for your components. I can't find it now, but someone commented this was their strategy in an issue/discussion here.theme.cssThis is where any custom theme variables/overrides lives. It is also where any custom variants go (ie: darkMode: class equivelant).
base.cssThis is where the base layer is extended to include styles based on html elements and not classes.
utilities.cssAny utility that components will either reference or generic utilities that aren't components.
component.cssThis is where you can declare your component styles that can reference any previously declared utility.
Package Configuration
This is kind of ripped directly from the tailwindcss code and how that
package.jsonis setup.build.jsThis file just copies the contents of the
libfolder to the folder you want it to go to. In the example below it is just copying the files to the root directory of the package.package.json{ "name": "@demo/plugin", "type": "module", "main": "./index.css", "files": [ "components", "base.css", "theme.css", "utilities.css", "index.css" ], "exports": { ".": { "style": "./index.css" }, "./package.json": "./package.json", "./index.css": "./index.css", "./index": "./index.css" }, "scripts": { "build": "node build.js" } ... }Consuming Package
Once the user installs the package all they have to do is add import it in their entry
cssfile.Beta Was this translation helpful? Give feedback.
All reactions