Skip to content

Commit

Permalink
fix(esbuild): expose output_css string directly; remove boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Apr 8, 2021
1 parent d1f07dd commit 060b781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions packages/esbuild/esbuild.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ See https://esbuild.github.io/api/#splitting for more details
),
"output_css": attr.output(
mandatory = False,
doc = "Name of the output css file when bundling",
doc = """Declare a .css file will be output next to output bundle.
If your JS code contains import statements that import .css files, esbuild will place the
content in a file next to the main output file, which you'll need to declare. If your output
file is named 'foo.js', you should set this to 'foo.css'.""",
),
"platform": attr.string(
default = "browser",
Expand Down Expand Up @@ -283,16 +287,14 @@ For further information about esbuild, see https://esbuild.github.io/
""",
)

def esbuild_macro(name, output_dir = False, output_css = False, **kwargs):
def esbuild_macro(name, output_dir = False, **kwargs):
"""esbuild helper macro around the `esbuild_bundle` rule
For a full list of attributes, see the `esbuild_bundle` rule
Args:
name: The name used for this rule and output files
output_dir: If `True`, produce a code split bundle in an output directory
output_css: If `True`, declare name.css as an output, which is the
case when your code imports a css file.
**kwargs: All other args from `esbuild_bundle`
"""

Expand All @@ -316,6 +318,5 @@ def esbuild_macro(name, output_dir = False, output_css = False, **kwargs):
name = name,
output = output,
output_map = output_map,
output_css = None if not output_css else "%s.css" % name,
**kwargs
)
2 changes: 1 addition & 1 deletion packages/esbuild/test/css/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ esbuild(
"--resolve-extensions=.mjs,.js",
],
entry_point = "main.ts",
output_css = True,
output_css = "with_css.css",
deps = [
":main",
],
Expand Down

0 comments on commit 060b781

Please sign in to comment.