-
Notifications
You must be signed in to change notification settings - Fork 13
postcss_multi_binary()
additional outputs
#64
Comments
Currently, all the outputs of That said, if it's worth the pain for you, I don't think it's unreasonable to add support for that feature. |
Thinking about this more, it's actually a bit tricky to leverage # Aggregate a bunch of files, possibly in different packages.
filegroup(
name = "css_files",
srcs = ["..."],
)
postcss_multi_binary(
name = "binary",
srcs = [":css_files"],
additional_outputs = ["???"], # Don't know what all the files in `:css_files` are.
plugins = {
"//some/plugin/emitting/a/json/file/for/each/css/input": "",
},
) Hypothetically, the same problem exists with I wonder if a better approach might be to create a directory and then have plugins put excess files in that directory. Then it would be up to the user to extract the relevant files separately. Using the same example: filegroup(
name = "css_files",
srcs = ["..."],
)
postcss_multi_binary(
name = "binary",
srcs = [":css_files"],
# Creates a new `output_directory/` folder.
# Plugins are responsible for writing additional outputs files here.
additional_outputs_dir = "output_directory",
plugins = {
"//some/plugin/emitting/a/json/file/for/each/css/input": """[{
// Configure the plugin to write to the additional outputs directory.
outputDir: 'output_directory/',
}]""",
},
)
genrule(
name = "consumer",
# Depend on the additional outputs directory which contains a JSON file for each CSS input.
srcs = ["output_directory"],
outs = # ...
cmd = """
find $< -name "*.json" -type f -exec do-something-useful-with-json {} \;
"""
) This way, postcss_multi_binary(
name = "binary",
additional_outputs_dir = "output_directory",
# ...
)
genrule(
name = "consumer",
srcs = ["output_directory"],
outs = ["special_file.txt"],
cmd = "cp $(location output_directory)/some/path/to/a/special/file.txt $(location special_file.txt)",
) I think configuring plugins is the most awkward part of this since the plugin must support writing to a specific location. It is also awkward because To your point about Do you have any thoughts about an |
Related: #63 (comment). |
I noticed that
postcss_multi_binary()
does not seem to have anadditional_outputs
parameter likepostcss_binary()
does. This means the multi binary rule can't be used with a plugin that outputs additional files (such aspostcss-modules
, which is the motivating example).Is this a deliberate omission due to some technical or philosophical reason, or is it just an oversight? I could probably put together a PR if we agree this is worth adding.
The text was updated successfully, but these errors were encountered: