i have managed to get my tailwind compiler "workin...
# general
g
i have managed to get my tailwind compiler "working" ->
./pants export-codegen
is exporting a css file. but somehow i'm to stupid to get that into my python project. i have a dependency defined in my python_sources pointing to my custom tailwind_sources rule i am surely missing something, but i dont get it after reading the pants source
h
but somehow i'm to stupid
Not at all. This stuff isn't necessarily intuitive, and I'm glad you reached out for help 🙂 What does your
GenerateSourcesRequest
subclass look like?
g
Copy code
class TailwindSourcesField(MultipleSourcesField):
    expected_file_extensions = (".js", ".scss")
    help = "tada"


class GenerateCssFromTailwindRequest(GenerateSourcesRequest):
    input = TailwindSourcesField
    output = SingleSourceField
    dependencies = DependenciesField


class TailwindTarget(Target):
    alias = "tailwind_sources"
    core_fields = (*COMMON_TARGET_FIELDS, TailwindSourcesField, Dependencies, Tags)
    help = "todo... :("
b
I'm gonna guess its a
FileSourceField
generator? If so
file
sources aren't "embedded". Try out
ResourceSourceField
h
yeah so you'll want to change
SingleSourceField
to be
ResourceSourceField
, probably
g
ah, ok, thats the missing link ^^
h
You're on step 5 of this guide now: https://www.pantsbuild.org/docs/plugins-codegen#target-type-already-exists Basically, most backends don't include all sources by default. For example, Python will include Python sources, resources, and sometimes files. It ignores Java sources etc. (The call sites also have to set
enable_codegen=True
)
g
its definitely hard to grasp some of the concepts. some of them seem like pure magic. but if you do not believe in magic you read the source and then you get lost there 😄
magic 1
1
🪄 1
ok, that worked. is something like a tailwind scss to css compiler something worth sharing with the project?
h
yay! probably not something we'd land in pantsbuild/pants given the greater lack currently of JS support, but it would be awesome if you're willing to post to GitHub so others can reference it
g
its using the bundled compiler thats standanlone. i download it with
Copy code
class TailwindCompiler(ExternalTool):
    options_scope = "tailwind-compiler"
    help = "tailwind compiler cli tool"

    default_version = "v3.1.8"
    default_known_versions = [
        "v3.1.8|macos_arm64 |839470b477af349a91cb72fd20da03820a9ce50d3b20095e039d7de19e4b1c3e|45868800",
...
👍 1
ok, then i will try to polish it a little bit. im not sure if its sfw right now 😄
❤️ 1
w
FYI - I think you could use the NPXProcess for this, but nothing wrong (and probably a lot right) about a standalone binary too
I think the hope for a JS/TS backend would be having a lot of this wrap into the preprocessor/bundler too - that's how I currently use Svelte + Tailwind
🙂 1
But, would be awesome to have more JS use cases and sources! Definitely drives things in the right direction
h
Thanks, we’d love this to be an official plugin at some point. Certainly once we have better webdev support.
I mean, you find this useful without JS support, so others may too!
g
what i am missing about pants is something like a "awesome pants" github repo pointing to user repos with plugins, with different types of "completeness", to just look at them, maybe use them, but learn a lot of them
today i realised that some bigger open source projects are using pants (with more ore less of the features: incrementally adoption you would say). but maybe it would help to show it to newbies like me?
👍 1
if i google "awesome pants" i find pants that are not fitting my size. im not a kardashian!
😆 1
w
today i realised that some bigger open source projects are using pants
I'd be interested in seeing these too. A lot of plugins end up in mainline Pants already, but maybe there are a bunch that are just less discoverable I have a few here (heads up that main might not build anymore, as I'm mid-refactoring) - but as mentioned, a bunch just ended up in mainline 🙂 https://github.com/sureshjoshi/pants-plugins
b
I think as the plugin API stabilizes over time, plugins might pop up in the wild. Right now the only way to guarantee your plugins stability is to add it to mainline Pants (he types as he refactors 12 mainline formatters)
w
Could be worse, could be 13