-
-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli)!: add --write-transformed
option, disable source write back by default
#2948
Conversation
✅ Deploy Preview for unocss ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
packages/cli/src/cli-start.ts
Outdated
@@ -21,6 +21,7 @@ export async function startCli(cwd = process.cwd(), argv = process.argv, options | |||
}) | |||
.option('-c, --config [file]', 'Config file') | |||
.option('-w, --watch', 'Watch for file changes') | |||
.option('--update-source', 'Update source files with transformed utilities', { default: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this was a dangerous default we picked. I'd be happy to name it as --write-transformed
and default to false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I've updated the flag and made sure that files transformed with directive transformer are also covered by tests.
…sabled by default
…li-toggle-updating-source
--write-transformed
option, disable source write back by default
Would it be better to output transformed files instead of overwriting source files? |
Hello,
this humble PR adds
--update-source
--write-transformed
flag for@unocss/cli
used to toggle overwriting source files with transformed code.It is enabled by default to preserve the current behavior, but can be disabled in case another tool takes care of transforming utility classes on the HTML side.Background:
I'm trying to make UnoCSS work with Rust frameworks preferably without trade-offs like dropping Variant Groups. I've made a little macro for that purpose and hopefully it will evolve someday to be executed on a WASM bundler side rather than polluting source code.
Regardless of the final approach to rendering valid HTML classes, keeping the source files not-transformed is desirable. Otherwise the Variant Groups feature isn't really much of use :)