{"id":13659374,"url":"https://github.com/bazelbuild/rules_closure","last_synced_at":"2025-05-16T10:06:38.534Z","repository":{"id":5659470,"uuid":"53674704","full_name":"bazelbuild/rules_closure","owner":"bazelbuild","description":"Closure rules for Bazel","archived":false,"fork":false,"pushed_at":"2025-05-02T19:18:28.000Z","size":2075,"stargazers_count":155,"open_issues_count":83,"forks_count":112,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-02T20:25:30.781Z","etag":null,"topics":["bazel","closure-compiler","closure-library","closure-stylesheets","closure-templates","javascript","protobuf"],"latest_commit_sha":null,"homepage":"https://developers.google.com/closure","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bazelbuild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-03-11T15:00:03.000Z","updated_at":"2025-05-02T19:18:34.000Z","dependencies_parsed_at":"2024-03-18T20:17:25.033Z","dependency_job_id":"5450deaf-c3c3-4908-9013-10f9d534c1e7","html_url":"https://github.com/bazelbuild/rules_closure","commit_stats":{"total_commits":500,"total_committers":93,"mean_commits":5.376344086021505,"dds":0.5680000000000001,"last_synced_commit":"7860dec6f1d7870d720ea6ef3f599c0397866fc9"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazelbuild%2Frules_closure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazelbuild%2Frules_closure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazelbuild%2Frules_closure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazelbuild%2Frules_closure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bazelbuild","download_url":"https://codeload.github.com/bazelbuild/rules_closure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509476,"owners_count":22082891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","closure-compiler","closure-library","closure-stylesheets","closure-templates","javascript","protobuf"],"created_at":"2024-08-02T05:01:08.017Z","updated_at":"2025-05-16T10:06:38.512Z","avatar_url":"https://github.com/bazelbuild.png","language":"Java","readme":"# Closure Rules for Bazel (αlpha) [![Bazel CI build status](https://badge.buildkite.com/7569410e2a2661076591897283051b6d137f35102167253fed.svg)](https://buildkite.com/bazel/closure-compiler-rules-closure-postsubmit)\n\nJavaScript | Stylesheets | Miscellaneous\n--- | --- | ---\n[closure_js_library] | [closure_css_library] | [phantomjs_test]\n[closure_js_binary] | [closure_css_binary] | |\n[closure_js_test] | |\n\n## Overview\n\nClosure Rules provides a polished JavaScript build system for [Bazel] that\nemphasizes type safety, strictness, testability, and optimization. These rules\nare built with the [Closure Tools], which are what Google used to create\nwebsites like Google.com and Gmail. The goal of this project is to take the\nfrontend development methodology that Google actually uses internally, and make\nit easily available to outside developers.\n\nClosure Rules is an *abstract* build system. This is what sets it apart from\nGrunt, Gulp, Webpacker, Brunch, Broccoli, etc. These projects all provide a\nconcrete framework for explaining *how* to build your project. Closure Rules\ninstead provides a framework for declaring *what* your project is. Closure Rules\nis then able to use this abstract definition to infer an optimal build strategy.\n\nClosure Rules is also an *austere* build system. The Closure Compiler doesn't\nplay games. It enforces a type system that can be stricter than Java. From a\nstylistic perspective, Closure is [verbose] like Java; there's no cryptic\nsymbols or implicit behavior; the code says exactly what it's doing.  This sets\nClosure apart from traditional JavaScript development, where terseness was\nfavored over readability, because minifiers weren't very good.\n\n### What's Included\n\nClosure Rules bundles the following tools and makes them \"just work.\"\n\n- [Bazel]: The build system Google uses to manage a repository with petabytes of\n  code.\n- [Closure Compiler]: Type-safe, null-safe, optimizing JavaScript compiler that\n  transpiles [ECMASCRIPT6] to minified ES3 JavaScript that can run in any\n  browser.\n- [Closure Library]: Google's core JavaScript libraries.\n  JavaScript and Java. This is one of the most secure templating systems\n  available. It's where Google has put the most thought into preventing things\n  like XSS attacks. It also supports i18n and l10n.\n- [Closure Stylesheets]: CSS compiler supporting class name minification,\n  variables, functions, conditionals, mixins, and bidirectional layout.\n- [PhantomJS]: Headless web browser used for automating JavaScript unit tests in\n  a command line environment.\n\n### Mailing Lists\n\n- [closure-rules-announce](https://groups.google.com/forum/#!forum/closure-rules-announce)\n- [closure-rules-discuss](https://groups.google.com/forum/#!forum/closure-rules-discuss)\n\n### Caveat Emptor\n\nClosure Rules is production ready, but its design is not yet finalized. Breaking\nchanges will be introduced. However they will be well-documented in the release\nnotes.\n\n## Setup\n\nFirst you must [install Bazel]. \n\nThen you add the following to your MODULE.bazel file:\n\n```bzl\nbazel_dep(name = \"io_bazel_rules_closure\")\n```\nThe root module has to declare the same override for rules_webtesting,\nrules_scala, and google_bazel_common temporarily until they are registered\nin BCR.\n\nYou are not required to install the Closure Tools, PhantomJS, or anything else\nfor that matter; they will be fetched automatically by Bazel.\n\n## Examples\n\nPlease see the test directories within this project for concrete examples of usage:\n\n- [//closure/testing/test](https://github.com/bazelbuild/rules_closure/tree/master/closure/testing/test)\n- [//closure/compiler/test](https://github.com/bazelbuild/rules_closure/tree/master/closure/compiler/test)\n- [//closure/stylesheets/test](https://github.com/bazelbuild/rules_closure/tree/master/closure/stylesheets/test)\n\n\n# Reference\n\n\n## closure\\_js\\_library\n\n```starlark\nload(\"@io_bazel_rules_closure//closure:defs.bzl\", \"closure_js_library\")\nclosure_js_library(name, srcs, data, deps, exports, suppress, convention,\n                   no_closure_library)\n```\n\nDefines a set of JavaScript sources.\n\nThe purpose of this rule is to define an abstract graph of JavaScript sources.\nIt must be used in conjunction with [closure_js_binary] to output a minified\nfile.\n\nThis rule will perform syntax checking and linting on your files. This can be\ntuned with the `suppress` attribute. To learn more about what the linter wants,\nread the [Google JavaScript Style Guide].\n\nStrict dependency checking is performed on the sources listed in each library\ntarget. See the documentation of the `deps` attribute for further information.\n\n#### Rule Polymorphism\n\nThis rule can be referenced as though it were the following:\n\n- [filegroup]: `srcs` will always be empty and `data` will contain all\n  transitive JS sources and data.\n\n### Arguments\n\n- **name:** ([Name]; required) A unique name for this rule. The standard\n  convention is that this be the same name as the Bazel package with `srcs =\n  glob(['*.js'])`. If it contains a subset of the `.js` srcs in the package,\n  then convention states that the `_lib` suffix should be used.\n\n- **srcs:** (List of [labels]; optional) The list of `.js` source files that\n  represent this library. This can include files marked as `@externs` or\n  `@nocompile`. This attribute is required unless the `exports` attribute is\n  being defined.\n\n- **data:** (List of [labels]; optional) Runfiles directly referenced by JS\n  sources in this rule. For example, if the JS generated injected an img tag\n  into the page with a hard coded image named foo.png, then you might want to\n  list that image here, so it ends up in the webserver runfiles.\n\n- **deps:** (List of [labels]; optional) Direct [dependency] list. These can\n  point to [closure_js_library], [closure_css_library] rules.\n\n- **exports:** (List of [labels]; optional) Listing dependencies here will cause\n  them to become *direct* dependencies in parent rules. This functions similarly\n  to [java_library.exports]. This can be used to create aliases for rules in\n  another package. It can also be also be used to export private targets within\n  the package. Another use is to roll up a bunch of fine-grained libraries into\n  a single big one.\n\n- **suppress** (List of String; optional; default is `[]`) List of codes the\n  linter should ignore. Warning and error messages that are allowed to be\n  suppressed, will display the codes for disabling it. For example, if the\n  linter says:\n\n  ```\n  foo.js:123: WARNING lintChecks JSC_MUST_BE_PRIVATE - Property bar_ must be marked @private\n  ```\n\n  Then the diagnostic code `\"JSC_MUST_BE_PRIVATE\"` can be used in the `suppress`\n  list. It is also possible to use the group code `\"lintChecks\"` to disable all\n  diagnostic codes associated with linting.\n\n  If a code is used that isn't necessary, an error is raised. Therefore the use\n  of fine-grained suppression codes is maintainable.\n\n- **convention** (String; optional; default is `\"CLOSURE\"`) Specifies the coding\n  convention which affects how the linter operates. This can be the following\n  values:\n\n  - `NONE`: Don't take any special practices into consideration.\n  - `CLOSURE`: Take [Closure coding conventions] into consideration when\n    linting. See the [Google JavaScript Style Guide] for more information.\n  - `GOOGLE`: Take [Google coding conventions] into consideration when\n    linting. See the [Google JavaScript Style Guide] for more information.\n\n- **no_closure_library** (Boolean; optional; default is `False`) Do not link\n  Closure Library [base.js]. If this flag is used, an error will be raised if\n  any `deps` do not also specify this flag.\n\n  All [closure_js_library] rules with nonempty `srcs` have an implicit\n  dependency on `@closure_library//:closure/goog/base.js`. This is a lightweight\n  file that boostraps very important functions, e.g. `goog.provide`. Linking\n  this file by default is important because:\n\n  1. It is logically impossible to say `goog.require('goog')`.\n  2. The Closure Compiler will sometimes generate synthetic code that calls\n     these functions. For example, the [ProcessEs6Modules] compiler pass turns\n     ES6 module directives into `goog.provide` / `goog.require` statements.\n\n  The only tradeoff is that when compiling in `WHITESPACE_ONLY` mode, this code\n  will show up in the resulting binary. Therefore this flag provides the option\n  to remove it.\n\n\n## closure\\_js\\_binary\n\n```starlark\nload(\"@io_bazel_rules_closure//closure:defs.bzl\", \"closure_js_binary\")\nclosure_js_binary(name, deps, css, debug, language, entry_points,\n                  dependency_mode, compilation_level, formatting,\n                  output_wrapper, property_renaming_report, defs)\n```\n\nTurns JavaScript libraries into a minified optimized blob of code.\n\nThis rule must be used in conjunction with [closure_js_library].\n\n#### Implicit Output Targets\n\n- *name*.js: A minified JavaScript file containing all transitive sources.\n\n- *name*.js.map: Sourcemap file mapping compiled sources to their raw\n  sources. This file can be loaded into browsers such as Chrome and Firefox to\n  view a stacktrace when an error is thrown by compiled sources.\n\n#### Rule Polymorphism\n\nThis rule can be referenced as though it were the following:\n\n- [filegroup]: `srcs` will be the .js and .js.map output files and `data` will\n  contain those files in addition to all transitive JS sources and data.\n\n- [closure_js_library]: `srcs` will be the .js output file, `language` will be\n  the output language, `deps` will be empty, `data` will contain all transitive\n  data, and `no_closure_library` will be `True`.\n\n### Arguments\n\n- **name:** ([Name]; required) A unique name for this rule. Convention states\n  that such rules be named `foo_bin` or `foo_dbg` if `debug = True`.\n\n- **deps:** (List of [labels]; required) Direct dependency list. This attribute\n  has the same meaning as it does in [closure_js_library].  These can point to\n  [closure_js_library] rules.\n\n- **css:** (Label; optional) CSS class renaming target, which must point to a\n  [closure_css_binary] rule. This causes the CSS name mapping file generated by\n  the CSS compiler to be included in the compiled JavaScript.  This tells\n  Closure Compiler how to minify CSS class names.\n\n  This attribute is required if any of JavaScript sources depend on\n  a [closure_css_library]. This rule will check that all the referenced CSS\n  libraries are present in the CSS binary.\n\n- **debug:** (Boolean; optional; default is `False`) Enables debug mode. Many\n  types of properties and variable names will be renamed to include `$`\n  characters, to help you spot bugs when using `ADVANCED` compilation\n  mode. Assert statements will not be stripped. Dependency directives will be\n  removed.\n\n- **language:** (String; optional; default is `\"ECMASCRIPT3\"`) Output language\n  variant to which library sources are transpiled. The default is ES3 because it\n  works in all browsers. The input language is calculated automatically based on\n  the `language` attribute of [closure_js_library] dependencies.\n\n- **entry_points:** (List of String; optional; default is `[]`) List of\n  unreferenced namespaces that should *not* be pruned by the compiler. This\n  should only be necessary when you want to invoke them from a `\u003cscript\u003e` tag on\n  your HTML page. See [Exports and Entry Points] to learn how this works with\n  the `@export` feature. For further context, see the Closure Compiler\n  documentation on [managing dependencies].\n\n- **dependency_mode:** (String; optional; default is `\"LOOSE\"`) In rare\n  circumstances you may want to set this flag to `\"STRICT\"`. See the\n  [Exports and Entry Points] unit tests and the Closure Compiler's\n  [managing dependencies] documentation for more information.\n\n- **compilation_level:** (String; optional; default is `\"ADVANCED\"`) Specifies\n  how minified you want your JavaScript binary to be. Valid options are:\n\n  - `ADVANCED`: Enables maximal minification and type checking. This is\n    *strongly* recommended for production binaries. **Warning:** Properties that\n    are accessed with dot notation will be renamed. Use quoted notation if this\n    presents problems for you, e.g. `foo['bar']`, `{'bar': ...}`.\n\n  - `SIMPLE`: Tells the Closure Compiler to function more like a traditional\n    JavaScript minifier. Type checking becomes disabled. Local variable names\n    will be minified, but object properties and global names will\n    not. Namespaces will be managed. Code that will never execute will be\n    removed. Local functions and variables can be inlined, but globals can not.\n\n  - `WHITESPACE_ONLY`: Tells the Closure Compiler to strip whitespace and\n    comments. Transpilation between languages will still work. Type checking\n    becomes disabled. No symbols will be renamed. Nothing will be inlined.\n    Dependency statements will not be removed. **ProTip:** If you're using the\n    Closure Library, you'll need to look into the `CLOSURE_NO_DEPS` and\n    `goog.ENABLE_DEBUG_LOADER` options in order to execute the compiled output.)\n\n- **formatting:** (String; optional) Specifies what is passed to the\n  `--formatting` flag of the Closure Compiler. The following options are valid:\n\n  - `PRETTY_PRINT`\n  - `PRINT_INPUT_DELIMITER`\n  - `SINGLE_QUOTES`\n\n- **output_wrapper:** (String; optional) Interpolate output into this string at\n  the place denoted by the marker token `%output%`. Use the marker token\n  `%output|jsstring%` to do JS string escaping on the output. The default\n  behavior is to generate code that pollutes the global namespace. Many users\n  will want to set this to `\"(function(){%output%}).call(this);\"` instead. See\n  the [Closure Compiler FAQ][output-wrapper-faq] for more details.\n\n- **property_renaming_report:** (File; optional) Output file for property\n  renaming report. It will contain lines in the form of `old:new`. This feature\n  has some fringe use cases, such as minifying JSON messages. However it's\n  recommended that you use protobuf instead.\n\n- **defs:** (List of strings; optional) Specifies additional flags to be passed\n  to the Closure Compiler, e.g. `\"--hide_warnings_for=some/path/\"`. To see what\n  flags are available, run:\n  `bazel run @io_bazel_rules_closure//third_party/java/jscomp:main -- --help`\n\n### Support for AngularJS\n\nWhen compiling AngularJS applications, you need to pass custom flags to the\nClosure Compiler. This can be accomplished by adding the following to your\n[closure_js_binary] rule:\n\n```starlark\nclosure_js_binary(\n    # ...\n    defs = [\n        \"--angular_pass\",\n        \"--export_local_property_definitions\",\n    ],\n)\n```\n\n## closure\\_js\\_test\n\n```starlark\nload(\"@io_bazel_rules_closure//closure:defs.bzl\", \"closure_js_test\")\nclosure_js_test(name, srcs, data, deps, css, html, language, suppress,\n                compilation_level, entry_points, defs)\n```\n\nRuns JavaScript unit tests inside a headless web browser.\n\nThis is a build macro that composes [closure_js_library], [closure_js_binary],\nand [phantomjs_test].\n\nA test is defined as any function in the global namespace that begins with\n`test`, `setUp`, or `tearDown`. You are not required to `@export` these\nfunctions. If you don't have a global namespace, because you're using\n`goog.module` or `goog.scope`, then you must register your test functions with\n`goog.testing.testSuite`.\n\nEach test file should require `goog.testing.jsunit` and `goog.testing.asserts`\nbecause they run the tests and provide useful [testing functions][asserts] such\nas `assertEquals()`.\n\nAny JavaScript file related to testing is strongly recommended to contain a\n`goog.setTestOnly()` statement in the file. However this is not required,\nbecause some projects might not want to directly reference Closure Library\nfunctions.\n\n#### No Network Access\n\nYour test will run within a hermetically sealed environment. You are not allowed\nto send HTTP requests to any external servers. It is expected that you'll use\nClosure Library mocks for things like XHR. However a local HTTP server is\nstarted up on a random port that allows to request runfiles under the\n`/filez/WORKSPACE_NAME/` path.\n\n#### Rule Polymorphism\n\nThis rule can be referenced as though it were the following:\n\n- [filegroup]: `srcs` will be the outputted executable, `data` will contain\n  all transitive sources, data, and other runfiles.\n\n### Arguments\n\n- **name:** ([Name]; required) A unique name for this rule.\n\n- **srcs:** (List of [labels]; required) List of `_test.js` source files that\n  register test functions.\n\n- **deps:** (List of [labels]; optional) Direct dependency list passed along to\n  [closure_js_library].\n\n- **data:** (List of [labels]; optional) Passed to [closure_js_library].\n\n- **css:** Passed to [closure_js_binary].\n\n- **html:** Passed to [phantomjs_test].\n\n- **language:** Passed to [closure_js_binary].\n\n- **compilation_level:** Passed to [closure_js_binary]. Setting this to\n  `\"WHITESPACE_ONLY\"` will cause tests to run significantly faster (at the\n  expense of type checking.)\n\n- **suppress:** Passed to [closure_js_library].\n\n- **entry_points:** If a dict, the source file is looked up for the value to pass to [closure_js_binary].  Otherwise, passed directly to [closure_js_binary].\n\n- **defs:** Passed to [closure_js_binary].\n\n\n## phantomjs\\_test\n\n```starlark\nload(\"@io_bazel_rules_closure//closure:defs.bzl\", \"phantomjs_test\")\nphantomjs_test(name, data, deps, html, harness, runner)\n```\n\nRuns PhantomJS (QtWebKit) for unit testing purposes.\n\nThis is a low level rule. Please use the [closure_js_test] macro if possible.\n\n#### Rule Polymorphism\n\nThis rule can be referenced as though it were the following:\n\n- [filegroup]: `srcs` will be the outputted executable, `data` will contain\n  all transitive sources, data, and other runfiles.\n\n### Arguments\n\n- **name:** ([Name]; required) Unique name for this rule.\n\n- **data:** (List of [labels]; optional) Additional runfiles for the local HTTP\n  server to serve, under the `/filez/` + repository path. This attribute should\n  not be necessary, because the transitive runfile data is already collected\n  from dependencies.\n\n- **deps:** (List of [labels]; required) Labels of Skylark rules exporting\n  `transitive_js_srcs`. Each source will be inserted into the webpage in its own\n  `\u003cscript\u003e` tag based on a depth-first preordering.\n\n- **html:** (Label; optional; default is\n  `\"@io_bazel_rules_closure//closure/testing:empty.html\"`) HTML file containing\n  DOM structure of virtual web page *before* `\u003cscript\u003e` tags are automatically\n  inserted. Do not include a doctype in this file.\n\n- **harness:** (Label; required; default is\n  `\"@io_bazel_rules_closure//closure/testing:phantomjs_harness\"`) JS binary or\n  library exporting a single source file, to be used as the PhantomJS outer\n  script.\n\n- **runner:** (Label; optional; default is\n  `\"@io_bazel_rules_closure//closure/testing:phantomjs_jsunit_runner\"`) Same as\n  `deps` but guaranteed to be loaded inside the virtual web page last. This\n  should run whatever tests got loaded by `deps` and then invoke `callPhantom`\n  to report the result to the `harness`.\n\n\n## closure\\_css\\_library\n\n```starlark\nload(\"@io_bazel_rules_closure//closure:defs.bzl\", \"closure_css_library\")\nclosure_css_library(name, srcs, data, deps)\n```\n\nDefines a set of CSS stylesheets.\n\nThis rule does not compile your stylesheets; it is used in conjunction with\n[closure_css_binary] which produces the minified CSS file.\n\nThis rule should be referenced by any [closure_js_library] rule whose sources\ncontain a `goog.getCssName('foo')` call if `foo` is a CSS class name defined by\nthis rule.\n\n#### Rule Polymorphism\n\nThis rule can be referenced as though it were the following:\n\n- [filegroup]: `srcs` will be the generated JS output files and `data` will\n  contain all transitive CSS/GSS sources and data.\n\n- [closure_js_library]: `srcs` is empty, `data` is the transitive CSS sources\n  and data, and `no_closure_library` is `True`. However the\n  closure\\_css\\_library rule does pass special information along when used as a\n  dep in closure\\_js\\_library. See its documentation to learn more.\n\n### Arguments\n\n- **name:** ([Name]; required) A unique name for this rule. Convention states\n  that this end with `_lib`.\n\n- **srcs:** (List of [labels]; required) A list of `.gss` or `.css` source files\n  that represent this library.\n\n  The order of stylsheets is `srcs` is undefined. If a CSS file overrides\n  definitions in another CSS file, then each file must be specified in separate\n  [closure_css_library] targets. That way Bazel can order your CSS definitions\n  based on the depth-first preordering of dependent rules.\n\n  It is strongly recommended you use `@provide` and `@require` statements in\n  your stylesheets so the CSS compiler can assert that the ordering is accurate.\n\n- **data:** (List of [labels]; optional) Runfiles directly referenced by CSS\n  sources in this rule. For example, if the CSS has a `url(foo.png)` then the\n  data attribute of its rule should be set to `[\"foo.png\"]` so the image is\n  available in the web server runfiles.\n\n- **deps:** (List of [labels]; optional) List of other [closure_css_library]\n  targets on which the CSS files in `srcs` depend.\n\n- **orientation:** (String; optional; default is `\"LTR\"`) Defines the text\n  direction for which this CSS was designed. This value can be:\n\n  - `LTR`: Outputs a sheet suitable for left to right display.\n  - `RTL`: Outputs a sheet suitable for right to left display.\n\n  An error will be raised if any `deps` do not have the same orientation. CSS\n  libraries with different orientations can be linked together by creating an\n  intermediary [closure_css_binary] that flips its orientation.\n\n\n## closure\\_css\\_binary\n\n```starlark\nload(\"@io_bazel_rules_closure//closure:defs.bzl\", \"closure_css_binary\")\nclosure_css_binary(name, deps, renaming, debug, defs)\n```\n\nTurns stylesheets defined by [closure_css_library] rules into a single minified\nCSS file.\n\nClosure-specific syntax such as variables, functions, conditionals, and mixins\nwill be evaluated and turned into normal CSS. The documentation on using these\nfeatures can be found [here][Closure Stylesheets].\n\nUnlike most CSS minifiers, this will minify class names by default. So this rule\ncan be referenced by the `css` flag of [closure_js_binary], in order to let the\nClosure Compiler know how to substitute the minified class names. See the\n`renaming` documentation below for more information.\n\n#### Implicit Output Targets\n\n- *name*.css: A minified CSS file defining the transitive closure of dependent\n  stylesheets compiled in a depth-first preordering.\n\n- *name*.css.map: [CSS sourcemap file][css-sourcemap]. This tells browsers like\n  Chrome and Firefox where your CSS definitions are located in their original\n  source files.\n\n- *name*.css.js: JavaScript file containing a `goog.setCssNameMapping()`\n  statement which tells the Closure Compiler and Library how to minify CSS class\n  names. The use of this file is largely handled transparently by the build\n  system. The user should only need to worry about this file when rendering Soy\n  templates from Java code, because its contents will need to be parsed into a\n  map using a regular expression, which is then passed to the Soy Tofu Java\n  runtime.\n\n#### Rule Polymorphism\n\nThis rule can be referenced as though it were the following:\n\n- [filegroup]: `srcs` will be the generated .css, .css.map, and .css.js output\n  files. `data` will contain all transitive CSS/GSS sources and data.\n\n- [closure_css_library]: `srcs` is the output .css file, `data` is the\n  transitive CSS sources and data, and `orientation` is the output orientation.\n\n### Arguments\n\n- **name:** ([Name]; required) A unique name for this rule. Convention states\n  that such rules be named `foo_bin` or `foo_dbg` if `debug = True`.\n\n- **deps:** (List of [labels]; required) List of [closure_css_library] rules to\n  compile. All dependencies must have their `orientation` attribute set to the\n  same value.\n\n- **renaming:** (Boolean; optional; default is `True`) Enables CSS class name\n  minification. This is one of the most powerful features of the Closure Tools.\n  By default, this will turn class names like `.foo-bar` into things like\n  `.a-b`. If `debug = True` then it will be renamed `.foo_-bar_`.\n\n  In order for this to work, you must update your JavaScript code to use the\n  `goog.getCssName(\"foo-bar\")` when referencing class names. JavaScript\n  library targets that reference CSS classes must add the appropriate CSS\n  library to its `deps` attribute. The `css` attribute of the\n  [closure_js_binary] also needs to be updated to point to this CSS binary\n  target, so the build system can verify (at compile time) that your CSS and\n  JS binaries are both being compiled in a harmonious way.\n\n- **debug:** (Boolean; optional; default is `False`) Enables debug mode, which\n  causes the compiled stylesheet to be pretty printed. If `renaming = True` then\n  class names will be renamed, but still readable to humans.\n\n- **orientation:** (String; optional; default is `\"NOCHANGE\"`) Specify this\n  option to perform automatic right to left conversion of the input. You can\n  choose between:\n\n  - `NOCHANGE`: Uses same orientation as was specified in dependent libraries.\n  - `LTR`: Outputs a sheet suitable for left to right display.\n  - `RTL`: Outputs a sheet suitable for right to left display.\n\n  The input orientation is calculated from the `orientation` flag of all\n  [closure_css_library] targets listed in `deps`. If the input orientation is\n  different than the requested output orientation, then 'left' and 'right'\n  values in direction sensitive style rules are flipped. If the input already\n  has the desired orientation, this option effectively does nothing except for\n  defining `GSS_LTR` and `GSS_RTL`, respectively.\n\n- **vendor:** (String; optional; default is `None`) Creates\n  browser-vendor-specific output by stripping all proprietary browser-vendor\n  properties from the output except for those associated with this vendor. Valid\n  values are:\n\n  - `WEBKIT`\n  - `MOZILLA`\n  - `MICROSOFT`\n  - `OPERA`\n  - `KONQUEROR`\n\n  The default behavior is to not strip any browser-vendor properties.\n\n- **defs:** (List of strings; optional) Specifies additional flags to be passed\n  to the Closure Stylesheets compiler. To see what flags are available, run:\n  `bazel run //closure/stylesheets:ClosureCommandLineCompiler -- --help`\n\n\n[Bazel]: http://bazel.build/\n[Closure Compiler]: https://developers.google.com/closure/compiler/\n[Closure Library]: https://developers.google.com/closure/library/\n[Closure Stylesheets]: https://github.com/google/closure-stylesheets\n[Closure Tools]: https://developers.google.com/closure/\n[Closure coding conventions]: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/ClosureCodingConvention.java\n[ECMASCRIPT6]: http://es6-features.org/\n[Exports and Entry Points]: https://github.com/bazelbuild/rules_closure/blob/master/closure/compiler/test/exports_and_entry_points/BUILD\n[Google JavaScript Style Guide]: https://google.github.io/styleguide/jsguide.html\n[Google coding conventions]: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleCodingConvention.java\n[Name]: https://docs.bazel.build/versions/master/build-ref.html#name\n[PhantomJS]: http://phantomjs.org/\n[ProcessEs6Modules]: https://github.com/google/closure-compiler/blob/1281ed9ded137eaf578bb65a588850bf13f38aa4/src/com/google/javascript/jscomp/ProcessEs6Modules.java\n[acyclic]: https://en.wikipedia.org/wiki/Directed_acyclic_graph\n[asserts]: https://github.com/google/closure-library/blob/master/closure/goog/testing/asserts.js#L1308\n[base.js]: https://github.com/google/closure-library/blob/master/closure/goog/base.js\n[install Bazel]: https://docs.bazel.build/versions/master/install.html\n[blockers]: https://github.com/bazelbuild/rules_closure/labels/launch%20blocker\n[closure_css_binary]: #closure_css_binary\n[closure_css_library]: #closure_css_library\n[closure_grpc_web_library]: https://github.com/grpc/grpc-web/blob/9b7b2d5411c486aa646ba2491cfd894d5352775b/bazel/closure_grpc_web_library.bzl#L149\n[closure_js_binary]: #closure_js_binary\n[closure_js_library]: #closure_js_library\n[closure_js_test]: #closure_js_test\n[coffeescript]: http://coffeescript.org/\n[compiler-issue]: https://github.com/google/closure-compiler/issues/new\n[css-sourcemap]: https://developer.chrome.com/devtools/docs/css-preprocessors\n[dependency]: https://docs.bazel.build/versions/master/build-ref.html#dependencies\n[filegroup]: https://docs.bazel.build/versions/master/be/general.html#filegroup\n[idom-example]: https://github.com/bazelbuild/rules_closure/blob/80d493d5ffc3099372929a8cd4a301da72e1b43f/closure/templates/test/greeter_idom.js\n[java_library.exports]: https://docs.bazel.build/versions/master/be/java.html#java_library.exports\n[java_library]: https://docs.bazel.build/versions/master/be/java.html#java_library\n[jquery]: http://jquery.com/\n[labels]: https://docs.bazel.build/versions/master/build-ref.html#labels\n[managing dependencies]: https://github.com/google/closure-compiler/wiki/Managing-Dependencies\n[output-wrapper-faq]: https://github.com/google/closure-compiler/wiki/FAQ#when-using-advanced-optimizations-closure-compiler-adds-new-variables-to-the-global-scope-how-do-i-make-sure-my-variables-dont-collide-with-other-scripts-on-the-page\n[phantomjs-bug]: https://github.com/ariya/phantomjs/issues/14028\n[phantomjs_test]: #phantomjs_test\n","funding_links":[],"categories":["Starlark (7)","Additional language support"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazelbuild%2Frules_closure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbazelbuild%2Frules_closure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazelbuild%2Frules_closure/lists"}