├── .bazelci └── presubmit.yml ├── .bazelversion ├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .gitignore ├── BUILD ├── CONTRIBUTING.md ├── DEVELOPING.md ├── LICENSE ├── README.md ├── WORKSPACE ├── examples ├── additional_outputs │ ├── BUILD │ ├── list-selectors.js │ └── style.css ├── autoprefixer │ ├── BUILD │ └── style.css ├── custom_plugin │ ├── BUILD │ ├── style.css │ └── unquote.js ├── custom_plugin_ts │ ├── BUILD │ ├── style.css │ └── unquote.ts ├── data_attr │ ├── BUILD │ ├── header.js │ ├── header.txt │ └── style.css ├── multi_binary │ ├── BUILD │ ├── style1.css │ └── style2.css ├── multi_sourcemap │ ├── BUILD │ ├── style1.css │ └── style2.css ├── positional_data_attr │ ├── BUILD │ ├── header.js │ ├── header.txt │ └── style.css ├── rtlcss │ ├── BUILD │ └── style.css ├── sourcemap │ ├── BUILD │ └── style.scss └── wrapper │ ├── BUILD │ ├── style.css │ └── wrapper.sh ├── index.bzl ├── internal ├── BUILD ├── autoprefixer │ ├── BUILD │ └── build_defs.bzl ├── binary.bzl ├── multi_binary.bzl ├── plugin.bzl ├── rtlcss │ ├── BUILD │ └── build_defs.bzl ├── run.bzl ├── runner.js └── runner_bin.bzl ├── package.bzl ├── package.json ├── repositories.bzl ├── rules_nodejs_skylib.patch ├── tests └── BUILD ├── tsconfig.json └── yarn.lock /.bazelci/presubmit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | buildifier: 3 | version: latest 4 | tasks: 5 | ubuntu1804: 6 | build_targets: 7 | - "//..." 8 | test_targets: 9 | - "//..." 10 | ubuntu2004: 11 | build_targets: 12 | - "//..." 13 | test_targets: 14 | - "//..." 15 | macos: 16 | build_targets: 17 | - "//..." 18 | test_targets: 19 | - "//..." 20 | ubuntu1804_worker: 21 | platform: ubuntu1804 22 | build_targets: 23 | - "//..." 24 | test_targets: 25 | - "//..." 26 | build_flags: 27 | - "--strategy=PostCSSRunner=worker" 28 | test_flags: 29 | - "--strategy=PostCSSRunner=worker" 30 | ubuntu2004_worker: 31 | platform: ubuntu2004 32 | build_targets: 33 | - "//..." 34 | test_targets: 35 | - "//..." 36 | build_flags: 37 | - "--strategy=PostCSSRunner=worker" 38 | test_flags: 39 | - "--strategy=PostCSSRunner=worker" 40 | macos_worker: 41 | platform: macos 42 | build_targets: 43 | - "//..." 44 | test_targets: 45 | - "//..." 46 | build_flags: 47 | - "--strategy=PostCSSRunner=worker" 48 | test_flags: 49 | - "--strategy=PostCSSRunner=worker" 50 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 3.0.0 -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM launcher.gcr.io/google/nodejs 2 | 3 | # We are not running in prod. Allow yarn to fetch devDependencies. 4 | ENV NODE_ENV development 5 | 6 | # Use Bazelisk to fetch Bazel specified in .bazelversion. Also install Buildifier. 7 | RUN yarn global add @bazel/bazelisk @bazel/buildifier 8 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rules_postcss", 3 | "dockerFile": "Dockerfile", 4 | "settings": { 5 | "terminal.integrated.shell.linux": "/bin/bash" 6 | }, 7 | "extensions": ["bazelbuild.vscode-bazel"], 8 | // Run yarn from rules_nodejs to set up workspace dependencies. This runs 9 | // in the background after source code is mounted, so it's expected you'll see 10 | // "Another command (pid=...) is running" if you try Bazel straight away. 11 | "postCreateCommand": "bazel run @nodejs//:yarn", 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /bazel-* 3 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | 17 | # BEGIN-INTERNAL 18 | load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") 19 | load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") 20 | # END-INTERNAL 21 | 22 | bzl_library( 23 | name = "build_defs", 24 | srcs = ["index.bzl"], 25 | deps = [ 26 | "//internal:build_defs", 27 | "//internal/autoprefixer:build_defs", 28 | "//internal/rtlcss:build_defs", 29 | ], 30 | ) 31 | 32 | exports_files(["LICENSE"]) 33 | 34 | # BEGIN-INTERNAL 35 | stardoc( 36 | name = "docs", 37 | out = "doc.md", 38 | input = "index.bzl", 39 | symbol_names = [ 40 | "postcss_binary", 41 | "postcss_multi_binary", 42 | "postcss_plugin", 43 | ], 44 | deps = ["//:build_defs"], 45 | ) 46 | 47 | exports_files( 48 | ["tsconfig.json"], 49 | visibility = ["//visibility:public"], 50 | ) 51 | 52 | pkg_npm( 53 | name = "npm_package", 54 | srcs = [ 55 | "BUILD", 56 | "LICENSE", 57 | "README.md", 58 | "index.bzl", 59 | "package.bzl", 60 | "package.json", 61 | ], 62 | substitutions = { 63 | "@build_bazel_rules_postcss//": "@npm//@bazel/postcss/", 64 | }, 65 | deps = [ 66 | "//internal:package_contents", 67 | "//internal/autoprefixer:package_contents", 68 | "//internal/rtlcss:package_contents", 69 | ], 70 | ) 71 | # END-INTERNAL 72 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | ## Community Guidelines 26 | 27 | This project follows [Google's Open Source Community 28 | Guidelines](https://opensource.google.com/conduct/). 29 | -------------------------------------------------------------------------------- /DEVELOPING.md: -------------------------------------------------------------------------------- 1 | # For Developers 2 | 3 | This repo is in early stages of development, so these instructions are subject to change. 4 | 5 | ## Releasing 6 | 7 | Start from a clean checkout at master/HEAD. 8 | 9 | Googlers: you should npm login using the go/npm-publish service: `$ npm login --registry https://wombat-dressing-room.appspot.com` 10 | 11 | 1. `npm version [major|minor|patch]` (`major` if there are breaking changes, `minor` if there are new features, otherwise `patch`) 12 | 1. If publishing from inside Google, set NPM_REGISTRY="--registry https://wombat-dressing-room.appspot.com" in your environment 13 | 1. Build the npm package and publish it: `bazel run //:npm_package.pack` 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://badge.buildkite.com/bc5333505517af47aba68c0c464f17a8e596338b742e6df295.svg)](https://buildkite.com/bazel/rules-postcss) 2 | 3 | # PostCSS Rules for Bazel 4 | 5 | ## Rules 6 | 7 | * postcss_binary 8 | * postcss_multi_binary 9 | * postcss_plugin 10 | * autoprefixer 11 | 12 | ## Overview 13 | 14 | These build rules are used for post-processing CSS files via [PostCSS][postcss] 15 | with Bazel. 16 | 17 | [postcss]: https://postcss.org 18 | 19 | ## Setup 20 | 21 | ### Using npm and Node.js rules 22 | 23 | We recommend you use npm to install the PostCSS build rules if you use the 24 | [Node.js build rules][rules_nodejs], and **strongly recommend** using npm 25 | if you also depend or plan to depend on PostCSS in your local `package.json`. 26 | (For example, if PostCSS plugin(s) will form part of your repository's build 27 | pipeline.) 28 | 29 | Installing the PostCSS build rules via npm allows you to rely on its native 30 | package management functionality. If you depend on PostCSS in your local 31 | `package.json`, using npm also helps avoid version skew between PostCSS in 32 | your repository and these build rules. 33 | 34 | [rules_nodejs]: https://bazelbuild.github.io/rules_nodejs/ 35 | 36 | Add the `@bazel/postcss` npm package to your `devDependencies` in 37 | `package.json`. 38 | 39 | Your `WORKSPACE` should declare a `yarn_install` or `npm_install` rule named 40 | `npm`. 41 | See https://github.com/bazelbuild/rules_nodejs/#quickstart 42 | 43 | This causes the build rules to be made available under 44 | `@npm//@bazel/postcss:index.bzl`. 45 | 46 | Lastly, in your `WORKSPACE` file, add `rules_postcss` dependencies: 47 | 48 | ```python 49 | load("@npm//@bazel/postcss:package.bzl", "rules_postcss_dependencies") 50 | rules_postcss_dependencies() 51 | ``` 52 | 53 | **TODO:** Compare to using PostCSS directly using `rules_nodejs`. 54 | 55 | ### Using repository rules 56 | 57 | Add the following to your WORKSPACE file to add the external repositories for 58 | PostCSS, making sure to use the latest published versions: 59 | 60 | ```python 61 | http_archive( 62 | name = "build_bazel_rules_postcss", 63 | # Make sure to check for the latest version when you install 64 | url = "https://github.com/bazelbuild/rules_postcss/archive/0.5.0.tar.gz", 65 | strip_prefix = "rules_postcss-0.5.0", 66 | sha256 = "3f0c754f97e3940ea90f4d6408bfb2aefb3850e7941572b22b1b88579c428ff9", 67 | ) 68 | load("@build_bazel_rules_postcss//:package.bzl", "rules_postcss_dependencies") 69 | rules_postcss_dependencies() 70 | ``` 71 | 72 | This causes the build rules to be made available under 73 | `@build_bazel_rules_postcss//:index.bzl`. 74 | 75 | ## Basic Example 76 | 77 | To be documented. 78 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace( 2 | name = "build_bazel_rules_postcss", 3 | managed_directories = {"@npm": ["node_modules"]}, 4 | ) 5 | 6 | load("//:package.bzl", "rules_postcss_dependencies") 7 | 8 | rules_postcss_dependencies() 9 | 10 | load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") 11 | 12 | bazel_skylib_workspace() 13 | 14 | load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") 15 | 16 | stardoc_repositories() 17 | 18 | load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") 19 | 20 | yarn_install( 21 | name = "npm", 22 | package_json = "//:package.json", 23 | yarn_lock = "//:yarn.lock", 24 | ) 25 | 26 | load("//:repositories.bzl", "postcss_repositories") 27 | 28 | postcss_repositories() 29 | -------------------------------------------------------------------------------- /examples/additional_outputs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "postcss_binary", "postcss_plugin") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | postcss_plugin( 20 | name = "list_selectors", 21 | srcs = [ 22 | "list-selectors.js", 23 | ], 24 | node_require = "build_bazel_rules_postcss/examples/additional_outputs/list-selectors.js", 25 | ) 26 | 27 | postcss_binary( 28 | name = "style_processed", 29 | src = "style.css", 30 | additional_outputs = ["selectors.md"], 31 | plugins = { 32 | ":list_selectors": "[{ output: bazel.additionalOutputs[0] }]", 33 | }, 34 | ) 35 | -------------------------------------------------------------------------------- /examples/additional_outputs/list-selectors.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 The Bazel Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview Example PostCSS plugin that outputs a file listing all unique 19 | * CSS selectors found. 20 | */ 21 | 22 | const fs = require('fs'); 23 | const path = require('path'); 24 | const postcss = require('postcss'); 25 | 26 | // Outputs a file listing all unique CSS selectors found. 27 | module.exports = postcss.plugin('list-selectors', (opts = {}) => { 28 | return css => { 29 | let totalSelectors = 0; 30 | const selectorCounts = {}; 31 | css.walkRules(rule => { 32 | for (const selector of rule.selectors) { 33 | if (!(selector in selectorCounts)) { 34 | selectorCounts[selector] = 0; 35 | } 36 | selectorCounts[selector]++; 37 | totalSelectors++; 38 | } 39 | }); 40 | 41 | let markdown = `# Found ${Object.keys(selectorCounts).length} unique selectors` 42 | + ` (of ${totalSelectors} total)\n`; 43 | for (let selector in selectorCounts) { 44 | markdown += `\n- ${selector} (${selectorCounts[selector]} total)` 45 | } 46 | 47 | fs.writeFileSync(opts.output, markdown); 48 | }; 49 | }); 50 | -------------------------------------------------------------------------------- /examples/additional_outputs/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 12px; 3 | } 4 | 5 | .container, .image.full-width { 6 | margin: 0 auto; 7 | width: 800px; 8 | } 9 | 10 | .container { 11 | background: #fff; 12 | } 13 | 14 | .image { 15 | box-shadow: 0 0 3px rgba(0, 0, 0, 0.5); 16 | } 17 | 18 | .image.full-width { 19 | box-shadow: none; 20 | } 21 | -------------------------------------------------------------------------------- /examples/autoprefixer/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "autoprefixer") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | AUTO_PREFIXER_BROWSERS = "ie >= 9, edge >= 12, firefox >= 42, chrome >= 32, safari >= 8, opera >= 38, ios_saf >= 9.2, android >= 4.3, and_uc >= 9.9" 20 | 21 | autoprefixer( 22 | name = "autoprefixer", 23 | src = "style.css", 24 | out = "style_processed.css", 25 | browsers = AUTO_PREFIXER_BROWSERS, 26 | ) 27 | -------------------------------------------------------------------------------- /examples/autoprefixer/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 42px 'Comic Sans MS'; 3 | flex: 42 -42 auto; 4 | } 5 | -------------------------------------------------------------------------------- /examples/custom_plugin/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "postcss_binary", "postcss_plugin") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | postcss_plugin( 20 | name = "unquote", 21 | srcs = [ 22 | "unquote.js", 23 | ], 24 | node_require = "build_bazel_rules_postcss/examples/custom_plugin/unquote.js", 25 | ) 26 | 27 | postcss_binary( 28 | name = "style_processed", 29 | src = "style.css", 30 | plugins = { 31 | ":unquote": "", 32 | }, 33 | ) 34 | -------------------------------------------------------------------------------- /examples/custom_plugin/style.css: -------------------------------------------------------------------------------- 1 | @media screen and (max-width: unquote("$(sidebar.width)")) { 2 | body { 3 | font: unquote("$(blog.title.font.size)") 'Comic Sans MS'; 4 | flex: 42 -42 auto; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/custom_plugin/unquote.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 The Bazel Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview Example PostCSS plugin that introduces an "unquote" function 19 | * to stylesheets. 20 | */ 21 | 22 | const postcss = require('postcss'); 23 | 24 | // Replaces all "unquote('hello')" found with "hello", supporting 25 | // both ' and ". Doesn't do quote escaping. 26 | module.exports = postcss.plugin('unquote', (opts = {}) => { 27 | /** 28 | * Unquote implementation. http://stackoverflow.com/a/19584742 29 | * @param {string} str 30 | * @return {string} The string with unquote instances handled. 31 | */ 32 | const unquoteStr = str => { 33 | if (str.indexOf('unquote(') !== -1) { 34 | return str.replace(/unquote\((["'])(.+?)\1\)/g, '$2'); 35 | } 36 | return str; 37 | }; 38 | 39 | return css => { 40 | // Handle declaration values in rules. 41 | css.walkRules(rule => { 42 | rule.walkDecls((decl, i) => decl.value = unquoteStr(decl.value)); 43 | }); 44 | // Handle params in @rules. 45 | css.walkAtRules(rule => rule.params = unquoteStr(rule.params)); 46 | }; 47 | }); 48 | -------------------------------------------------------------------------------- /examples/custom_plugin_ts/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@npm//@bazel/typescript:index.bzl", "ts_library") 16 | load("//:index.bzl", "postcss_binary", "postcss_plugin") 17 | 18 | package(default_visibility = ["//tests:__subpackages__"]) 19 | 20 | ts_library( 21 | name = "unquote_ts", 22 | srcs = ["unquote.ts"], 23 | deps = [ 24 | "@npm//@types", 25 | "@npm//postcss", 26 | ], 27 | ) 28 | 29 | filegroup( 30 | name = "unquote_js", 31 | srcs = [":unquote_ts"], 32 | output_group = "es5_sources", 33 | ) 34 | 35 | postcss_plugin( 36 | name = "unquote", 37 | srcs = [ 38 | ":unquote_js", 39 | ], 40 | node_require = "build_bazel_rules_postcss/examples/custom_plugin_ts/unquote.js", 41 | ) 42 | 43 | postcss_binary( 44 | name = "style_processed", 45 | src = "style.css", 46 | plugins = { 47 | ":unquote": "", 48 | }, 49 | ) 50 | -------------------------------------------------------------------------------- /examples/custom_plugin_ts/style.css: -------------------------------------------------------------------------------- 1 | @media screen and (max-width: unquote("$(sidebar.width)")) { 2 | body { 3 | font: unquote("$(blog.title.font.size)") 'Comic Sans MS'; 4 | flex: 42 -42 auto; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/custom_plugin_ts/unquote.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 The Bazel Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview Example PostCSS plugin that introduces an "unquote" function 19 | * to stylesheets. 20 | */ 21 | 22 | import * as postcss from 'postcss'; 23 | 24 | // Replaces all "unquote('hello')" found with "hello", supporting 25 | // both ' and ". Doesn't do quote escaping. 26 | module.exports = postcss.plugin('unquote', () => { 27 | /** 28 | * Unquote implementation. http://stackoverflow.com/a/19584742 29 | * @param str 30 | * @return The string with unquote instances handled. 31 | */ 32 | const unquoteStr = (str: string) => { 33 | if (str.indexOf('unquote(') !== -1) { 34 | return str.replace(/unquote\((["'])(.+?)\1\)/g, '$2'); 35 | } 36 | return str; 37 | }; 38 | 39 | return (css: postcss.Root) => { 40 | // Handle declaration values in rules. 41 | css.walkRules(rule => { 42 | rule.walkDecls((decl, i) => decl.value = unquoteStr(decl.value)); 43 | }); 44 | // Handle params in @rules. 45 | css.walkAtRules(rule => rule.params = unquoteStr(rule.params)); 46 | }; 47 | }); 48 | -------------------------------------------------------------------------------- /examples/data_attr/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "postcss_binary", "postcss_plugin") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | postcss_plugin( 20 | name = "header", 21 | srcs = ["header.js"], 22 | node_require = "build_bazel_rules_postcss/examples/data_attr/header.js", 23 | ) 24 | 25 | postcss_binary( 26 | name = "style_processed", 27 | src = "style.css", 28 | named_data = {"header": "header.txt"}, 29 | plugins = { 30 | ":header": "[{ path: bazel.data.header[0] }]", 31 | }, 32 | ) 33 | -------------------------------------------------------------------------------- /examples/data_attr/header.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2020 The Bazel Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview Example PostCSS plugin that injects a text file as a header 19 | * comment. 20 | */ 21 | 22 | const fs = require('fs'); 23 | const postcss = require('postcss'); 24 | 25 | module.exports = postcss.plugin('header', (opts = {}) => { 26 | const contents = fs.readFileSync(opts.path, 'utf8').trim(); 27 | 28 | return css => { 29 | css.prepend(postcss.comment({text: contents})); 30 | }; 31 | }); 32 | -------------------------------------------------------------------------------- /examples/data_attr/header.txt: -------------------------------------------------------------------------------- 1 | This goes at the beginning of the file. 2 | -------------------------------------------------------------------------------- /examples/data_attr/style.css: -------------------------------------------------------------------------------- 1 | @media screen and (max-width: 10px) { 2 | body { 3 | font: 42px 'Comic Sans MS'; 4 | flex: 42 -42 auto; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/multi_binary/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "postcss_multi_binary", "postcss_plugin") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | AUTO_PREFIXER_BROWSERS = "ie >= 9, edge >= 12, firefox >= 42, chrome >= 32, safari >= 8, opera >= 38, ios_saf >= 9.2, android >= 4.3, and_uc >= 9.9" 20 | 21 | postcss_plugin( 22 | name = "autoprefixer", 23 | node_require = "autoprefixer", 24 | deps = ["@npm//autoprefixer"], 25 | ) 26 | 27 | postcss_multi_binary( 28 | name = "styles", 29 | srcs = [ 30 | "style1.css", 31 | "style2.css", 32 | ], 33 | output_pattern = "{rule}/{dir}/{name}", 34 | plugins = { 35 | ":autoprefixer": "[{ browsers: '%s' }]" % AUTO_PREFIXER_BROWSERS, 36 | }, 37 | ) 38 | -------------------------------------------------------------------------------- /examples/multi_binary/style1.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 42px 'Comic Sans MS'; 3 | flex: 42 -42 auto; 4 | } 5 | -------------------------------------------------------------------------------- /examples/multi_binary/style2.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 42px 'Comic Sans MS'; 3 | flex: 42 -42 auto; 4 | } 5 | -------------------------------------------------------------------------------- /examples/multi_sourcemap/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "postcss_multi_binary", "postcss_plugin") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | AUTO_PREFIXER_BROWSERS = "ie >= 9, edge >= 12, firefox >= 42, chrome >= 32, safari >= 8, opera >= 38, ios_saf >= 9.2, android >= 4.3, and_uc >= 9.9" 20 | 21 | postcss_plugin( 22 | name = "autoprefixer", 23 | node_require = "autoprefixer", 24 | ) 25 | 26 | postcss_multi_binary( 27 | name = "styles", 28 | srcs = [ 29 | "style1.css", 30 | "style2.css", 31 | ], 32 | output_pattern = "{rule}/{dir}/{name}", 33 | plugins = { 34 | ":autoprefixer": "[{ browsers: '%s' }]" % AUTO_PREFIXER_BROWSERS, 35 | }, 36 | sourcemap = True, 37 | deps = ["@npm//autoprefixer"], 38 | ) 39 | -------------------------------------------------------------------------------- /examples/multi_sourcemap/style1.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 42px 'Comic Sans MS'; 3 | flex: 42 -42 auto; 4 | } 5 | -------------------------------------------------------------------------------- /examples/multi_sourcemap/style2.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 42px 'Comic Sans MS'; 3 | flex: 42 -42 auto; 4 | } 5 | -------------------------------------------------------------------------------- /examples/positional_data_attr/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "postcss_binary", "postcss_plugin") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | postcss_plugin( 20 | name = "header", 21 | srcs = ["header.js"], 22 | node_require = "build_bazel_rules_postcss/examples/positional_data_attr/header.js", 23 | ) 24 | 25 | postcss_binary( 26 | name = "style_processed", 27 | src = "style.css", 28 | data = ["header.txt"], 29 | plugins = { 30 | ":header": "[{ path: bazel.data[0] }]", 31 | }, 32 | ) 33 | -------------------------------------------------------------------------------- /examples/positional_data_attr/header.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2020 The Bazel Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview Example PostCSS plugin that injects a text file as a header 19 | * comment. 20 | */ 21 | 22 | const fs = require('fs'); 23 | const postcss = require('postcss'); 24 | 25 | module.exports = postcss.plugin('header', (opts = {}) => { 26 | const contents = fs.readFileSync(opts.path, 'utf8').trim(); 27 | 28 | return css => { 29 | css.prepend(postcss.comment({text: contents})); 30 | }; 31 | }); 32 | -------------------------------------------------------------------------------- /examples/positional_data_attr/header.txt: -------------------------------------------------------------------------------- 1 | This goes at the beginning of the file. 2 | -------------------------------------------------------------------------------- /examples/positional_data_attr/style.css: -------------------------------------------------------------------------------- 1 | @media screen and (max-width: 10px) { 2 | body { 3 | font: 42px 'Comic Sans MS'; 4 | flex: 42 -42 auto; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/rtlcss/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "rtlcss") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | rtlcss( 20 | name = "rtlcss", 21 | src = "style.css", 22 | out = "style_processed.css", 23 | ) 24 | -------------------------------------------------------------------------------- /examples/rtlcss/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | direction: ltr; 3 | margin: 5px 10px 20px 25px; 4 | padding: 4px 8px 12px 16px; 5 | border-width: 1px 2px 3px 4px; 6 | } 7 | -------------------------------------------------------------------------------- /examples/sourcemap/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") 16 | load("//:index.bzl", "autoprefixer") 17 | 18 | package(default_visibility = ["//tests:__subpackages__"]) 19 | 20 | AUTO_PREFIXER_BROWSERS = "ie >= 9, edge >= 12, firefox >= 42, chrome >= 32, safari >= 8, opera >= 38, ios_saf >= 9.2, android >= 4.3, and_uc >= 9.9" 21 | 22 | sass_binary( 23 | name = "style", 24 | src = "style.scss", 25 | output_style = "expanded", 26 | ) 27 | 28 | autoprefixer( 29 | name = "autoprefixer", 30 | src = ":style", 31 | out = "style_processed.css", 32 | browsers = AUTO_PREFIXER_BROWSERS, 33 | sourcemap = True, 34 | ) 35 | -------------------------------------------------------------------------------- /examples/sourcemap/style.scss: -------------------------------------------------------------------------------- 1 | body { 2 | font: 42px 'Comic Sans MS'; 3 | flex: 42 -42 auto; 4 | } 5 | -------------------------------------------------------------------------------- /examples/wrapper/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//:index.bzl", "postcss_binary", "postcss_plugin") 16 | 17 | package(default_visibility = ["//tests:__subpackages__"]) 18 | 19 | postcss_plugin( 20 | name = "rtlcss", 21 | node_require = "rtlcss", 22 | deps = [ 23 | "@npm//rtlcss", 24 | ], 25 | ) 26 | 27 | sh_binary( 28 | name = "wrapper", 29 | srcs = ["wrapper.sh"], 30 | ) 31 | 32 | postcss_binary( 33 | name = "style_processed", 34 | src = "style.css", 35 | plugins = { 36 | ":rtlcss": "", 37 | }, 38 | wrapper = ":wrapper", 39 | ) 40 | -------------------------------------------------------------------------------- /examples/wrapper/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 42px 40px 38px 36px; 3 | } 4 | -------------------------------------------------------------------------------- /examples/wrapper/wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2020 The Bazel Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | echo "argv is: $@" 17 | 18 | executable=$1 19 | shift 20 | 21 | echo "wrapped executable is: $executable" 22 | 23 | echo "sliced argv is: $@" 24 | 25 | echo "running wrapped executable" 26 | 27 | $executable $@ 28 | 29 | echo "finished running wrapped executable" 30 | 31 | while [ $# -gt 0 ]; do 32 | if case $1 in "--outCssFile"*) true;; *) false;; esac; then 33 | # Take the argv after the flag --outCssFile 34 | shift 35 | outCssFile=$(printf '%s' "$1" | sed 's/--outCssFile=//') 36 | fi 37 | shift 38 | done 39 | 40 | echo "outCssFile is $outCssFile" 41 | 42 | echo "/*hello!*/" >> $outCssFile 43 | -------------------------------------------------------------------------------- /index.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Public API surface is re-exported here. 16 | 17 | Users should not load files under "/internal" 18 | """ 19 | 20 | load("@build_bazel_rules_postcss//internal:plugin.bzl", _postcss_plugin = "postcss_plugin") 21 | load("@build_bazel_rules_postcss//internal:binary.bzl", _postcss_binary = "postcss_binary") 22 | load("@build_bazel_rules_postcss//internal:multi_binary.bzl", _postcss_multi_binary = "postcss_multi_binary") 23 | load("@build_bazel_rules_postcss//internal/autoprefixer:build_defs.bzl", _autoprefixer = "autoprefixer") 24 | load("@build_bazel_rules_postcss//internal/rtlcss:build_defs.bzl", _rtlcss = "rtlcss") 25 | 26 | postcss_plugin = _postcss_plugin 27 | postcss_binary = _postcss_binary 28 | postcss_multi_binary = _postcss_multi_binary 29 | autoprefixer = _autoprefixer 30 | rtlcss = _rtlcss 31 | -------------------------------------------------------------------------------- /internal/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | 17 | filegroup( 18 | name = "package_contents", 19 | srcs = glob(["*"]), 20 | visibility = ["//:__pkg__"], 21 | ) 22 | 23 | bzl_library( 24 | name = "build_defs", 25 | srcs = glob(["*.bzl"]), 26 | visibility = ["//:__subpackages__"], 27 | deps = [ 28 | "@bazel_skylib//lib:dicts", 29 | "@bazel_skylib//lib:paths", 30 | "@build_bazel_rules_nodejs//:bzl", 31 | ], 32 | ) 33 | 34 | exports_files(["runner.js"]) 35 | -------------------------------------------------------------------------------- /internal/autoprefixer/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | load("@build_bazel_rules_postcss//internal:plugin.bzl", "postcss_plugin") 17 | 18 | filegroup( 19 | name = "package_contents", 20 | srcs = glob(["*"]), 21 | visibility = ["//:__pkg__"], 22 | ) 23 | 24 | bzl_library( 25 | name = "build_defs", 26 | srcs = glob(["*.bzl"]), 27 | visibility = ["//:__subpackages__"], 28 | deps = [ 29 | "//internal:build_defs", 30 | ], 31 | ) 32 | 33 | postcss_plugin( 34 | name = "autoprefixer", 35 | node_require = "autoprefixer", 36 | visibility = ["//visibility:public"], 37 | deps = [ 38 | "@npm//autoprefixer", 39 | ], 40 | ) 41 | -------------------------------------------------------------------------------- /internal/autoprefixer/build_defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Build rule for using autoprefixer to postprocess CSS.""" 16 | 17 | load("@build_bazel_rules_postcss//internal:binary.bzl", "postcss_binary") 18 | 19 | def autoprefixer( 20 | name, 21 | src, 22 | out, 23 | browsers = "> 1%", 24 | **kwargs): 25 | """Runs autoprefixer on the given source files located in the given fileset. 26 | 27 | Args: 28 | name: A unique label for this rule. 29 | src: Source file or target. 30 | out: Output file. 31 | browsers: Browers to target, in browserlist format (e.g., "last 1 version", 32 | or "> 5%, > 2% in US, Firefox > 20"). 33 | See https://github.com/ai/browserslist for more queries. If empty 34 | or blank, include all known prefixes. Default is '> 1%'. 35 | **kwargs: Additional arguments to pass to postcss_binary(). 36 | """ 37 | 38 | postcss_binary( 39 | name = name, 40 | plugins = { 41 | "@build_bazel_rules_postcss//internal/autoprefixer": "[{ overrideBrowserslist: '%s' }]" % (browsers), 42 | }, 43 | src = src, 44 | output_name = out, 45 | **kwargs 46 | ) 47 | -------------------------------------------------------------------------------- /internal/binary.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """PostCSS binary rule. 16 | 17 | Building a postcss_binary target builds an internal PostCSS runner, and runs 18 | it using a provided list of PostCSS plugins, against input .css (and optionally 19 | .css.map). 20 | """ 21 | 22 | load("@bazel_skylib//lib:dicts.bzl", "dicts") 23 | load(":runner_bin.bzl", "postcss_runner_bin") 24 | load(":run.bzl", "postcss_run") 25 | 26 | def postcss_binary( 27 | name, 28 | plugins, 29 | src, 30 | deps = [], 31 | additional_outputs = [], 32 | output_name = "", 33 | sourcemap = False, 34 | data = [], 35 | named_data = {}, 36 | wrapper = None, 37 | **kwargs): 38 | """Runs PostCSS. 39 | 40 | Args: 41 | name: The name of the build rule. 42 | plugins: A map of postcss_plugin targets to JavaScript config object 43 | strings. 44 | 45 | Plugin configurations are interpreted as JavaScript code, and can 46 | refer to the following pre-defined variables: 47 | 48 | * `bazel.binDir`: The root of Bazel's generated binary tree. 49 | 50 | * `bazel.additionalOutputs`: An array of all the file paths passed 51 | to the `additional_outputs` attribute of `postcss_binary`, to 52 | which a plugin is expected to write. 53 | 54 | * `bazel.data`: An array of all the file paths for targets passed to 55 | the `data` or `named_data` attribute of `postcss_binary`. 56 | 57 | `bazel.data.${name}` can also be used to access the file paths for 58 | individual targets passed to `named_data`. For example, if you 59 | pass `named_data = {"license": "license.txt"}`, you can access 60 | the path of the license file via `bazel.data.license[0]`. 61 | 62 | It's strongly recommended to use `named_data` over `data` when you 63 | want to access a specific target's file(s), and only use the array 64 | value to access *all* data files no matter which target they come 65 | from. 66 | 67 | src: The input .css, and optionally .css.map files. (This includes 68 | outputs from preprocessors such as sass_binary.) 69 | deps: Additional NodeJS modules the config depends on. The PostCSS 70 | module and plugin modules are always implicitly included. 71 | additional_outputs: Any additional outputs that are generated by the 72 | provided plugins. 73 | output_name: Output name. 74 | sourcemap: Whether to generate a source map. If False, any existing 75 | sourceMappingURL comment is deleted. 76 | data: Standard Bazel argument. 77 | named_data: A map from names to targets to use as data dependencies. 78 | This works just like `data` except that the targets' files can be 79 | accessed through `bazel.data.${name}`. 80 | wrapper: Wrapper for the postcss binary. If passed, the wrapper is run 81 | in place of the postcss binary, with an extra first arg pointing 82 | to the actual postcss binary. (Workers are not supported when using 83 | a wrapper.) 84 | **kwargs: Standard BUILD arguments to pass. 85 | """ 86 | 87 | runner_name = "%s.postcss_runner" % name 88 | 89 | postcss_runner_bin( 90 | name = runner_name, 91 | deps = deps + plugins.keys(), 92 | **dicts.add(kwargs, {"visibility": ["//visibility:private"]}) 93 | ) 94 | 95 | postcss_run( 96 | name = name, 97 | src = src, 98 | output_name = output_name, 99 | additional_outputs = additional_outputs, 100 | plugins = plugins, 101 | runner = runner_name, 102 | sourcemap = sourcemap, 103 | data = data, 104 | named_data = named_data, 105 | wrapper = wrapper, 106 | **kwargs 107 | ) 108 | -------------------------------------------------------------------------------- /internal/multi_binary.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """A rule that compiles multiple CSS files with the same PostCSS configuration. 16 | 17 | This works like `postcss_binary` except that it takes multiple CSS sources and 18 | declares a separate action for each of them. 19 | """ 20 | 21 | load("@bazel_skylib//lib:dicts.bzl", "dicts") 22 | load(":runner_bin.bzl", "postcss_runner_bin") 23 | load(":run.bzl", "postcss_multi_run") 24 | 25 | def postcss_multi_binary( 26 | name, 27 | plugins, 28 | srcs, 29 | output_pattern, 30 | sourcemap = False, 31 | deps = [], 32 | data = [], 33 | **kwargs): 34 | """Compiles multiple CSS files with the same PostCSS configuration. 35 | 36 | This should generally be avoided if postcss_binary would suffice. It's 37 | intended to be used when the set of files to compile aren't known during the 38 | loading phase. 39 | 40 | Args: 41 | name: The name of the build rule. 42 | plugins: A map of plugin Node.js require paths (following the 43 | requirements of rules_nodejs), with values being config objects 44 | for each respective plugin. 45 | srcs: The input .css (and optionally .css.map) files. If a .css.map file 46 | is passed, its corresponding .css file must also exist. 47 | output_pattern: A named pattern for the output file generated for each 48 | input CSS file. 49 | 50 | This pattern can include any or all of the following variables: 51 | 52 | * "{name}", the input CSS file's basename. 53 | * "{dir}", the input CSS file's directory name relative to the root 54 | of the workspace. 55 | * "{rule}", the name of this rule. 56 | 57 | It defaults to "{rule}/{name}". 58 | sourcemap: Whether to generate source maps. If False, any existing 59 | sourceMappingURL comments are deleted. 60 | deps: A list of NodeJS modules the config depends on. The PostCSS module 61 | is always implicitly included. 62 | data: Standard Bazel argument. 63 | **kwargs: Standard BUILD arguments to pass. 64 | 65 | """ 66 | 67 | runner_name = "%s.postcss_runner" % name 68 | 69 | postcss_runner_bin( 70 | name = runner_name, 71 | deps = deps + list(plugins.keys()), 72 | **dicts.add(kwargs, {"visibility": ["//visibility:private"]}) 73 | ) 74 | 75 | postcss_multi_run( 76 | name = name, 77 | srcs = srcs, 78 | output_pattern = output_pattern, 79 | plugins = plugins, 80 | runner = runner_name, 81 | sourcemap = sourcemap, 82 | data = data, 83 | **kwargs 84 | ) 85 | -------------------------------------------------------------------------------- /internal/plugin.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """PostCSS plugin rule. 16 | 17 | Bundling PostCSS plugins as postcss_plugin targets defines their grouping of 18 | Node.js source files, as well as promoting reuse of plugins across multiple 19 | postcss_binary targets. 20 | """ 21 | 22 | load("@build_bazel_rules_nodejs//:providers.bzl", "NpmPackageInfo") 23 | 24 | PostcssPluginInfo = provider("""Provides extra metadata about this PostCSS 25 | plugin required when using postcss_binary.""", fields = ["node_require"]) 26 | 27 | def _postcss_plugin_info_impl(ctx): 28 | return [ 29 | PostcssPluginInfo(node_require = ctx.attr.node_require), 30 | NpmPackageInfo( 31 | direct_sources = depset(ctx.files.srcs), 32 | sources = depset( 33 | ctx.files.srcs, 34 | transitive = [ 35 | dep[NpmPackageInfo].sources 36 | for dep in ctx.attr.deps 37 | if NpmPackageInfo in dep 38 | ], 39 | ), 40 | workspace = "npm", 41 | ), 42 | ] 43 | 44 | postcss_plugin_info = rule( 45 | implementation = _postcss_plugin_info_impl, 46 | attrs = { 47 | "node_require": attr.string( 48 | default = "", 49 | doc = """The Node.js require path for this plugin, following the 50 | format expected by the Node.js build rules.""", 51 | mandatory = True, 52 | ), 53 | "deps": attr.label_list(), 54 | "srcs": attr.label_list( 55 | allow_files = True, 56 | ), 57 | }, 58 | doc = """Metadata about a PostCSS plugin. 59 | 60 | This rule provides extra metadata about this PostCSS plugin required when using 61 | postcss_binary.""", 62 | ) 63 | 64 | def postcss_plugin( 65 | name, 66 | node_require, 67 | srcs = [], 68 | data = [], 69 | deps = [], 70 | **kwargs): 71 | """Represents a Node.js module that is a PostCSS plugin. 72 | 73 | This provides extra metadata about PostCSS plugins that will be consumed by 74 | postcss_binary. 75 | 76 | For plugins that are from npm, adding the module as a dep is sufficient. 77 | For plugins that are from local sources, the sources must be added to srcs. 78 | 79 | Args: 80 | name: The name of the build rule. 81 | node_require: The require for the Node.js module. 82 | srcs: JS sources for the Node.js module, if any. 83 | data: Non-JS data files needed for the Node.js module. 84 | deps: Node.js module dependencies. 85 | **kwargs: Standard BUILD arguments to pass. 86 | """ 87 | 88 | postcss_plugin_info( 89 | name = name, 90 | node_require = node_require, 91 | srcs = srcs, 92 | deps = deps, 93 | **kwargs 94 | ) 95 | -------------------------------------------------------------------------------- /internal/rtlcss/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | load("@build_bazel_rules_postcss//internal:plugin.bzl", "postcss_plugin") 17 | 18 | filegroup( 19 | name = "package_contents", 20 | srcs = glob(["*"]), 21 | visibility = ["//:__pkg__"], 22 | ) 23 | 24 | bzl_library( 25 | name = "build_defs", 26 | srcs = glob(["*.bzl"]), 27 | visibility = ["//:__subpackages__"], 28 | deps = [ 29 | "//internal:build_defs", 30 | ], 31 | ) 32 | 33 | postcss_plugin( 34 | name = "rtlcss", 35 | node_require = "rtlcss", 36 | visibility = ["//visibility:public"], 37 | deps = [ 38 | "@npm//rtlcss", 39 | ], 40 | ) 41 | -------------------------------------------------------------------------------- /internal/rtlcss/build_defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Build rule for using rtlcss to postprocess CSS.""" 16 | 17 | load("@build_bazel_rules_postcss//internal:binary.bzl", "postcss_binary") 18 | 19 | def rtlcss( 20 | name, 21 | src, 22 | out, 23 | **kwargs): 24 | """Runs rtlcss on the given source files located in the given fileset. 25 | 26 | Args: 27 | name: A unique label for this rule. 28 | src: Source file or target. 29 | out: Output file. 30 | **kwargs: Additional arguments to pass to postcss_binary(). 31 | """ 32 | 33 | postcss_binary( 34 | name = name, 35 | plugins = { 36 | "@build_bazel_rules_postcss//internal/rtlcss": "", 37 | }, 38 | src = src, 39 | output_name = out, 40 | **kwargs 41 | ) 42 | -------------------------------------------------------------------------------- /internal/run.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """PostCSS run rule. 16 | 17 | Runs a internal PostCSS runner, generated via the postcss_gen_runner rule.""" 18 | 19 | load("@build_bazel_rules_nodejs//:providers.bzl", "run_node") 20 | load("@bazel_skylib//lib:paths.bzl", "paths") 21 | load(":plugin.bzl", "PostcssPluginInfo") 22 | 23 | ERROR_INPUT_NO_PLUGINS = "No plugins were provided" 24 | ERROR_INPUT_NO_CSS = "Input of one file must be of a .css file" 25 | ERROR_INPUT_TWO_FILES = "Input of two files must be of a .css and .css.map file" 26 | ERROR_INPUT_TOO_MANY = "Input must be up to two files, a .css file, and optionally a .css.map file" 27 | 28 | def _run_one(ctx, input_css, input_map, output_css, output_map): 29 | """Compile a single CSS file to a single output file. 30 | 31 | Returns a list of ouputs generated by this action.""" 32 | 33 | if len(ctx.attr.plugins.items()) == 0: 34 | fail(ERROR_INPUT_NO_PLUGINS) 35 | 36 | # Generate the command line. 37 | args = ctx.actions.args() 38 | if ctx.executable.wrapper: 39 | args.add(ctx.executable.runner.path) 40 | args.add("--binDir", ctx.bin_dir.path) 41 | args.add("--cssFile", input_css.path) 42 | args.add("--outCssFile", output_css.path) 43 | 44 | data = [t.files for t in ctx.attr.data] + [t.files for t in ctx.attr.named_data.keys()] 45 | for files in data: 46 | args.add_all("--data", files) 47 | 48 | for (target, name) in ctx.attr.named_data.items(): 49 | for file in target.files.to_list(): 50 | args.add("--namedData", "%s:%s" % (name, file.path)) 51 | 52 | if hasattr(ctx.outputs, "additional_outputs"): 53 | args.add_all("--additionalOutputs", ctx.outputs.additional_outputs) 54 | 55 | if input_map: 56 | args.add("--cssMapFile", input_map.path) 57 | if ctx.attr.sourcemap: 58 | args.add("--outCssMapFile", output_map.path) 59 | 60 | # The command may only access files declared in inputs. 61 | inputs = depset( 62 | [input_css] + ([input_map] if input_map else []), 63 | transitive = data, 64 | ) 65 | 66 | outputs = [output_css] 67 | if ctx.attr.sourcemap: 68 | args.add("--sourcemap") 69 | outputs.append(output_map) 70 | 71 | if hasattr(ctx.outputs, "additional_outputs"): 72 | outputs.extend(ctx.outputs.additional_outputs) 73 | 74 | plugins = [] 75 | for plugin_key, plugin_options in ctx.attr.plugins.items(): 76 | node_require = plugin_key[PostcssPluginInfo].node_require 77 | args.add("--pluginRequires", node_require) 78 | args.add("--pluginArgs", plugin_options if plugin_options else "[]") 79 | 80 | # If a wrapper binary is passed, run it. It gets the actual binary as an 81 | # input and the path to it as the first arg. 82 | if ctx.executable.wrapper: 83 | # If using a wrapper, running as a worker is currently unsupported. 84 | ctx.actions.run( 85 | inputs = inputs, 86 | outputs = outputs, 87 | executable = ctx.executable.wrapper, 88 | tools = [ctx.executable.runner], 89 | arguments = [args], 90 | progress_message = "Running PostCSS wrapper on %s" % input_css.short_path, 91 | mnemonic = "PostCSSWrapper", 92 | ) 93 | else: 94 | args.use_param_file("@%s", use_always = True) 95 | args.set_param_file_format("multiline") 96 | run_node( 97 | ctx = ctx, 98 | inputs = inputs, 99 | outputs = outputs, 100 | executable = "runner", 101 | tools = [], 102 | arguments = [args], 103 | progress_message = "Running PostCSS runner on %s" % input_css.short_path, 104 | execution_requirements = {"supports-workers": "1"}, 105 | mnemonic = "PostCSSRunner", 106 | ) 107 | 108 | return outputs 109 | 110 | def _postcss_run_impl(ctx): 111 | # Get the list of files. Fail here if there are more than two files. 112 | file_list = ctx.files.src 113 | if len(file_list) > 2: 114 | fail(ERROR_INPUT_TOO_MANY) 115 | 116 | # Get the .css and .css.map files from the list, which we expect to always 117 | # contain a .css file, and optionally a .css.map file. 118 | input_css = None 119 | input_map = None 120 | for input_file in file_list: 121 | if input_file.extension == "css": 122 | if input_css != None: 123 | fail(ERROR_INPUT_TWO_FILES) 124 | input_css = input_file 125 | continue 126 | if input_file.extension == "map": 127 | if input_map != None: 128 | fail(ERROR_INPUT_TWO_FILES) 129 | input_map = input_file 130 | continue 131 | if input_css == None: 132 | fail(ERROR_INPUT_NO_CSS) 133 | 134 | outputs = _run_one( 135 | ctx = ctx, 136 | input_css = input_css, 137 | input_map = input_map, 138 | output_css = ctx.outputs.css_file, 139 | output_map = ctx.outputs.css_map_file if ctx.attr.sourcemap else None, 140 | ) 141 | 142 | return DefaultInfo(files = depset(outputs), runfiles = ctx.runfiles(files = outputs)) 143 | 144 | def _postcss_run_outputs(output_name, sourcemap): 145 | output_name = output_name or "%{name}.css" 146 | outputs = {"css_file": output_name} 147 | if sourcemap: 148 | outputs["css_map_file"] = output_name + ".map" 149 | return outputs 150 | 151 | def _reverse_named_data(names_to_labels): 152 | """Reverses the named_data parameter from names-to-labels to labels-to-names. 153 | 154 | Bazel only supports a map from labels to strings and not vice-versa, but it 155 | makes more sense to the user to have names be the keys.""" 156 | 157 | labels_to_names = {} 158 | for (name, label) in names_to_labels.items(): 159 | if label in labels_to_names: 160 | fail("Values in named_data must be unique. \"%s\" was used twice." % label) 161 | labels_to_names[label] = name 162 | 163 | return labels_to_names 164 | 165 | _postcss_run = rule( 166 | implementation = _postcss_run_impl, 167 | attrs = { 168 | "src": attr.label( 169 | allow_files = [".css", ".css.map"], 170 | mandatory = True, 171 | ), 172 | "output_name": attr.string(default = ""), 173 | "additional_outputs": attr.output_list(), 174 | "sourcemap": attr.bool(default = False), 175 | "data": attr.label_list(allow_files = True), 176 | "named_data": attr.label_keyed_string_dict(allow_files = True), 177 | "plugins": attr.label_keyed_string_dict( 178 | cfg = "exec", 179 | mandatory = True, 180 | ), 181 | "runner": attr.label( 182 | executable = True, 183 | cfg = "host", 184 | allow_files = True, 185 | mandatory = True, 186 | ), 187 | "wrapper": attr.label( 188 | executable = True, 189 | cfg = "host", 190 | allow_files = True, 191 | ), 192 | }, 193 | outputs = _postcss_run_outputs, 194 | ) 195 | 196 | def postcss_run(named_data = {}, **args): 197 | _postcss_run( 198 | named_data = _reverse_named_data(named_data), 199 | **args 200 | ) 201 | 202 | def _postcss_multi_run_impl(ctx): 203 | # A dict from .css filenames to two-element lists which contain 204 | # [CSS file, soucemap file]. It's an error for a sourcemap to exist 205 | # without a CSS file, but not vice versa. 206 | files_by_name = {} 207 | for f in ctx.files.srcs: 208 | if f.extension == "map": 209 | files_by_name.setdefault(_strip_extension(f.path), [None, None])[1] = f 210 | else: 211 | files_by_name.setdefault(f.path, [None, None])[0] = f 212 | 213 | outputs = [] 214 | for (input_css, input_map) in files_by_name.values(): 215 | if not input_css: 216 | fail("Source map file %s was passed without a corresponding CSS file." % input_map.path) 217 | 218 | output_name = ctx.attr.output_pattern.format( 219 | name = input_css.basename, 220 | dir = paths.dirname(input_css.short_path), 221 | rule = ctx.label.name, 222 | ) 223 | 224 | output_css = ctx.actions.declare_file(output_name) 225 | output_map = ctx.actions.declare_file(output_name + ".map") if ctx.attr.sourcemap else None 226 | 227 | outputs.extend(_run_one( 228 | ctx = ctx, 229 | input_css = input_css, 230 | input_map = input_map, 231 | output_css = output_css, 232 | output_map = output_map, 233 | )) 234 | 235 | return DefaultInfo(files = depset(outputs), runfiles = ctx.runfiles(files = outputs)) 236 | 237 | def _strip_extension(path): 238 | """Removes the final extension from a path.""" 239 | components = path.split(".") 240 | components.pop() 241 | return ".".join(components) 242 | 243 | _postcss_multi_run = rule( 244 | implementation = _postcss_multi_run_impl, 245 | attrs = { 246 | "srcs": attr.label_list( 247 | allow_files = [".css", ".css.map"], 248 | mandatory = True, 249 | ), 250 | "output_pattern": attr.string(default = "{rule}/{name}"), 251 | "sourcemap": attr.bool(default = False), 252 | "data": attr.label_list(allow_files = True), 253 | "named_data": attr.label_keyed_string_dict(allow_files = True), 254 | "plugins": attr.label_keyed_string_dict( 255 | cfg = "exec", 256 | mandatory = True, 257 | ), 258 | "runner": attr.label( 259 | executable = True, 260 | cfg = "host", 261 | allow_files = True, 262 | mandatory = True, 263 | ), 264 | "wrapper": attr.label( 265 | executable = True, 266 | cfg = "host", 267 | allow_files = True, 268 | ), 269 | }, 270 | ) 271 | 272 | def postcss_multi_run(named_data = {}, **args): 273 | _postcss_multi_run( 274 | named_data = _reverse_named_data(named_data), 275 | **args 276 | ) 277 | -------------------------------------------------------------------------------- /internal/runner.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 The Bazel Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview Node.js binary that runs PostCSS with specified inputs and 19 | * plugins, generated via a template. TEMPLATE_* symbols are substituted when 20 | * this binary is generated. 21 | */ 22 | 23 | const fs = require('fs'); 24 | const minimist = require('minimist'); 25 | const path = require('path'); 26 | const postcss = require('postcss'); 27 | const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']); 28 | const worker = require('@bazel/worker'); 29 | 30 | /** 31 | * Returns the argument named `name` as an array. 32 | * 33 | * Minimist automatically converts args that are passed multiple times into 34 | * arrays. This ensures a consistent representation if the same arg is passed 35 | * zero or one times. 36 | */ 37 | function argAsArray(args, name) { 38 | const value = args[name]; 39 | if (!value) return []; 40 | if (typeof value === 'string') return [value]; 41 | return value; 42 | } 43 | 44 | function compile(rawArgs) { 45 | const args = minimist(rawArgs); 46 | const cwd = process.cwd(); 47 | 48 | const data = argAsArray(args, 'data'); 49 | for (const pair of argAsArray(args, 'namedData')) { 50 | const [name, value] = pair.split(':'); 51 | (data[name] = data[name] || []).push(value); 52 | } 53 | 54 | // These variables are documented in `postcss_binary`'s docstring and are 55 | // fair game for plugin configuration to read. 56 | const bazel = { 57 | binDir: args.binDir, 58 | data: data, 59 | additionalOutputs: argAsArray(args, 'additionalOutputs'), 60 | }; 61 | 62 | const cssString = fs.readFileSync(args.cssFile, 'utf8'); 63 | 64 | const options = { 65 | // The path of the input CSS file. 66 | from: args.cssFile, 67 | // The path of the output CSS file. 68 | to: args.outCssFile, 69 | map: args.sourcemap 70 | ? { 71 | // Don't output source map inline, we want it as a separate file. 72 | inline: false, 73 | // Whether to add (or modify, if already existing) the 74 | // sourceMappingURL comment in the output .css to point to the 75 | // output .css.map. 76 | annotation: true, 77 | } 78 | : false, 79 | }; 80 | 81 | // Get absolute output paths before we change directory. 82 | const outCssPath = path.join(cwd, args.outCssFile); 83 | const outCssMapPath = 84 | args.outCssMapFile ? path.join(cwd, args.outCssMapFile) : null; 85 | 86 | // We use two parallel arrays, PostCSS plugin requires => strings of JS args. 87 | // To use in PostCSS, convert these into the actual plugin instances. 88 | const pluginRequires = argAsArray(args, 'pluginRequires'); 89 | const pluginArgs = argAsArray(args, 'pluginArgs'); 90 | const pluginInstances = pluginRequires.map( 91 | (nodeRequire, i) => { 92 | // Try and resolve this plugin as a module identifier. 93 | let plugin; 94 | try { 95 | plugin = require(nodeRequire); 96 | } catch { } 97 | 98 | // If it fails, use the runfile helper in case it's a workspace file. 99 | if (!plugin) { 100 | try { 101 | plugin = require(runfiles.resolve(nodeRequire)); 102 | } catch { } 103 | } 104 | 105 | // If that still fails, throw an error. 106 | if (!plugin) { 107 | const e = new Error( 108 | `could not resolve plugin with node require ${nodeRequire}`); 109 | e.code = 'MODULE_NOT_FOUND'; 110 | throw e; 111 | } 112 | 113 | return plugin.apply(this, eval(pluginArgs[i])); 114 | }); 115 | 116 | return postcss(pluginInstances) 117 | .process(cssString, options) 118 | .then( 119 | result => { 120 | fs.writeFileSync(outCssPath, result.css); 121 | if (args.sourcemap && result.map) { 122 | fs.writeFileSync(outCssMapPath, result.map.toString()); 123 | } 124 | return true; 125 | }, 126 | e => { 127 | // cssnano (and possibly other packages) can emit errors that aren't 128 | // instances of PostCSS's CssSyntaxError class, but that have a 129 | // postcssNode field which allows us to construct our own 130 | // CssSyntaxError. We do so because its error formatting is more 131 | // thorough. 132 | if (e.postcssNode) e = e.postcssNode.error(e.message); 133 | 134 | console.warn(e.toString()); 135 | return false; 136 | }); 137 | } 138 | 139 | if (worker.runAsWorker(process.argv)) { 140 | worker.log('PostCSS runner starting as worker...'); 141 | worker.runWorkerLoop(compile); 142 | } else { 143 | console.log('PostCSS runner starting standalone...'); 144 | 145 | // If the first param starts with @, this is a Bazel param file. Otherwise, 146 | // treat the params as coming directly from argv. 147 | let args; 148 | if (process.argv[2].startsWith('@')) { 149 | const paramFile = process.argv[2].replace(/^@/, ''); 150 | args = fs.readFileSync(paramFile, 'utf-8').trim().split('\n'); 151 | } else { 152 | args = process.argv.slice(2); 153 | } 154 | 155 | compile(args).then( 156 | success => { 157 | // Arbitrary exit code for failure, otherwise we exit succesfully. 158 | if (!success) { 159 | process.exit(2); 160 | } 161 | }); 162 | } 163 | -------------------------------------------------------------------------------- /internal/runner_bin.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """PostCSS runner binary rule. 16 | 17 | Sets up common deps and entry point for the PostCSS runner.""" 18 | 19 | load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") 20 | 21 | def postcss_runner_bin( 22 | name, 23 | deps, 24 | **kwargs): 25 | """Sets up a nodejs_binary for the PostCSS runner with common deps. 26 | 27 | Args: 28 | name: The name of the build rule. 29 | deps: Additional NodeJS modules the runner will depend on. The PostCSS 30 | module is always implicitly included. 31 | **kwargs: Additional arguments to pass to nodejs_binary(). 32 | """ 33 | 34 | nodejs_binary( 35 | name = name, 36 | entry_point = "@build_bazel_rules_postcss//internal:runner.js", 37 | data = [ 38 | "@npm//minimist", 39 | "@npm//postcss", 40 | "@npm//@bazel/worker", 41 | ] + deps, 42 | **kwargs 43 | ) 44 | -------------------------------------------------------------------------------- /package.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Fetches transitive dependencies required for using the PostCSS rules""" 16 | 17 | load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") 18 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 19 | 20 | def _include_if_not_defined(repo_rule, name, **kwargs): 21 | if name not in native.existing_rules(): 22 | repo_rule(name = name, **kwargs) 23 | 24 | def rules_postcss_dependencies(): 25 | # Skylib. 26 | _include_if_not_defined( 27 | http_archive, 28 | name = "bazel_skylib", 29 | urls = [ 30 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", 31 | "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", 32 | ], 33 | sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", 34 | ) 35 | 36 | _include_if_not_defined( 37 | git_repository, 38 | name = "io_bazel_stardoc", 39 | remote = "https://github.com/bazelbuild/stardoc.git", 40 | commit = "247c2097e7346778ac8d03de5a4770d6b9890dc5", 41 | ) 42 | 43 | # NodeJS rules. 44 | _include_if_not_defined( 45 | http_archive, 46 | name = "build_bazel_rules_nodejs", 47 | # Un-dummy-ify skylib loading so that we can dep on bzl_library targets 48 | # from rules_nodejs (i.e. those for nodejs_binary). Having correct deps 49 | # in bzl_library is required for skydoc to function. 50 | patches = ["@build_bazel_rules_postcss//:rules_nodejs_skylib.patch"], 51 | sha256 = "5bf77cc2d13ddf9124f4c1453dd96063774d755d4fc75d922471540d1c9a8ea8", 52 | urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.0.0/rules_nodejs-2.0.0.tar.gz"], 53 | ) 54 | 55 | # Sass rules. 56 | _include_if_not_defined( 57 | http_archive, 58 | name = "io_bazel_rules_sass", 59 | sha256 = "9dcfba04e4af896626f4760d866f895ea4291bc30bf7287887cefcf4707b6a62", 60 | urls = [ 61 | "https://github.com/bazelbuild/rules_sass/archive/1.26.3.zip", 62 | "https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/1.26.3.zip", 63 | ], 64 | strip_prefix = "rules_sass-1.26.3", 65 | ) 66 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@bazel/postcss", 3 | "description": "PostCSS rules for Bazel", 4 | "license": "Apache-2.0", 5 | "version": "0.6.0", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/bazelbuild/rules_postcss.git" 9 | }, 10 | "bugs": { 11 | "url": "https://github.com/bazelbuild/rules_postcss/issues" 12 | }, 13 | "keywords": [ 14 | "postcss", 15 | "css", 16 | "bazel" 17 | ], 18 | "dependencies": { 19 | "@bazel/worker": "^2.0.0", 20 | "@types/node": "^12.12.7", 21 | "autoprefixer": "^9.8.6", 22 | "minimist": "1.2.6", 23 | "postcss": "^7.0.7", 24 | "rtlcss": "^2.4.0", 25 | "typescript": "^3.7.2" 26 | }, 27 | "peerDependencies": { 28 | "postcss": "^7.0.7" 29 | }, 30 | "devDependencies": { 31 | "@bazel/typescript": "^2.0.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /repositories.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Install PostCSS toolchain dependencies""" 16 | 17 | load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version") 18 | load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories") 19 | load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies") 20 | 21 | def postcss_repositories(): 22 | """Set up environment for PostCSS.""" 23 | 24 | check_rules_nodejs_version("2.0.0") 25 | 26 | rules_sass_dependencies() 27 | 28 | sass_repositories() 29 | -------------------------------------------------------------------------------- /rules_nodejs_skylib.patch: -------------------------------------------------------------------------------- 1 | diff --git BUILD.bazel BUILD.bazel 2 | index efda7cf..3a51205 100755 3 | --- BUILD.bazel 4 | +++ BUILD.bazel 5 | @@ -12,9 +12,7 @@ 6 | # See the License for the specific language governing permissions and 7 | # limitations under the License. 8 | 9 | -# bazel_skylib mocked out 10 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 11 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 12 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 13 | load("@build_bazel_rules_nodejs//:index.bzl", "COMMON_REPLACEMENTS", "pkg_npm") 14 | # defaults.bzl not included in distribution 15 | # load("//:tools/defaults.bzl", "codeowners", "pkg_tar") 16 | @@ -43,6 +41,7 @@ bzl_library( 17 | "//internal/common:bzl", 18 | "//internal/generated_file_test:bzl", 19 | "//internal/linker:bzl", 20 | + "//internal/node:bzl", 21 | "//internal/pkg_npm:bzl", 22 | "//internal/pkg_web:bzl", 23 | "//internal/providers:bzl", 24 | diff --git internal/bazel_integration_test/BUILD.bazel internal/bazel_integration_test/BUILD.bazel 25 | index eab3886..bbc085e 100755 26 | --- internal/bazel_integration_test/BUILD.bazel 27 | +++ internal/bazel_integration_test/BUILD.bazel 28 | @@ -12,9 +12,7 @@ 29 | # See the License for the specific language governing permissions and 30 | # limitations under the License. 31 | 32 | -# bazel_skylib mocked out 33 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 34 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 35 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 36 | load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") 37 | 38 | package(default_visibility = ["//visibility:public"]) 39 | diff --git internal/common/BUILD.bazel internal/common/BUILD.bazel 40 | index f0412d4..da34750 100755 41 | --- internal/common/BUILD.bazel 42 | +++ internal/common/BUILD.bazel 43 | @@ -12,9 +12,7 @@ 44 | # See the License for the specific language governing permissions and 45 | # limitations under the License. 46 | 47 | -# bazel_skylib mocked out 48 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 49 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 50 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 51 | load(":check_version_test.bzl", "check_version_test_suite") 52 | 53 | licenses(["notice"]) # Apache 2.0 54 | diff --git internal/generated_file_test/BUILD internal/generated_file_test/BUILD 55 | index 3e753a7..2d4b2ef 100755 56 | --- internal/generated_file_test/BUILD 57 | +++ internal/generated_file_test/BUILD 58 | @@ -1 +1,9 @@ 59 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 60 | + 61 | +bzl_library( 62 | + name = "bzl", 63 | + srcs = glob(["*.bzl"]), 64 | + visibility = ["//visibility:public"], 65 | +) 66 | + 67 | exports_files(["bundle.js"]) 68 | \ No newline at end of file 69 | diff --git internal/js_library/BUILD.bazel internal/js_library/BUILD.bazel 70 | index 054a5f3..6f29827 100755 71 | --- internal/js_library/BUILD.bazel 72 | +++ internal/js_library/BUILD.bazel 73 | @@ -1,6 +1,4 @@ 74 | -# bazel_skylib mocked out 75 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 76 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 77 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 78 | 79 | bzl_library( 80 | name = "bzl", 81 | diff --git internal/linker/BUILD.bazel internal/linker/BUILD.bazel 82 | index 40140a2..7531995 100755 83 | --- internal/linker/BUILD.bazel 84 | +++ internal/linker/BUILD.bazel 85 | @@ -1,4 +1,12 @@ 86 | 87 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 88 | + 89 | +bzl_library( 90 | + name = "bzl", 91 | + srcs = glob(["*.bzl"]), 92 | + visibility = ["//visibility:public"], 93 | +) 94 | + 95 | exports_files([ 96 | "index.js", 97 | "runfiles_helper.js", 98 | diff --git internal/node/BUILD.bazel internal/node/BUILD.bazel 99 | index 09cf2b4..f739ff9 100755 100 | --- internal/node/BUILD.bazel 101 | +++ internal/node/BUILD.bazel 102 | @@ -12,9 +12,7 @@ 103 | # See the License for the specific language governing permissions and 104 | # limitations under the License. 105 | 106 | -# bazel_skylib mocked out 107 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 108 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 109 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 110 | load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") 111 | 112 | package(default_visibility = ["//visibility:public"]) 113 | diff --git internal/npm_install/BUILD.bazel internal/npm_install/BUILD.bazel 114 | index 6fd3f08..d2b7b8f 100755 115 | --- internal/npm_install/BUILD.bazel 116 | +++ internal/npm_install/BUILD.bazel 117 | @@ -1,6 +1,4 @@ 118 | -# bazel_skylib mocked out 119 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 120 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 121 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 122 | load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") 123 | 124 | 125 | diff --git internal/pkg_npm/BUILD.bazel internal/pkg_npm/BUILD.bazel 126 | index 486ea55..ea0addb 100755 127 | --- internal/pkg_npm/BUILD.bazel 128 | +++ internal/pkg_npm/BUILD.bazel 129 | @@ -1,6 +1,4 @@ 130 | -# bazel_skylib mocked out 131 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 132 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 133 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 134 | load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") 135 | 136 | package(default_visibility = ["//visibility:public"]) 137 | diff --git internal/pkg_web/BUILD.bazel internal/pkg_web/BUILD.bazel 138 | index 6bb3fa7..3f0bf48 100755 139 | --- internal/pkg_web/BUILD.bazel 140 | +++ internal/pkg_web/BUILD.bazel 141 | @@ -1,6 +1,4 @@ 142 | -# bazel_skylib mocked out 143 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 144 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 145 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 146 | load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") 147 | 148 | 149 | diff --git internal/providers/BUILD.bazel internal/providers/BUILD.bazel 150 | index ace773c..7125f08 100755 151 | --- internal/providers/BUILD.bazel 152 | +++ internal/providers/BUILD.bazel 153 | @@ -12,9 +12,7 @@ 154 | # See the License for the specific language governing permissions and 155 | # limitations under the License. 156 | 157 | -# bazel_skylib mocked out 158 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 159 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 160 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 161 | 162 | bzl_library( 163 | name = "bzl", 164 | diff --git third_party/github.com/bazelbuild/bazel-skylib/BUILD third_party/github.com/bazelbuild/bazel-skylib/BUILD 165 | index 10db32d..16b5313 100755 166 | --- third_party/github.com/bazelbuild/bazel-skylib/BUILD 167 | +++ third_party/github.com/bazelbuild/bazel-skylib/BUILD 168 | @@ -1,6 +1,4 @@ 169 | -# bazel_skylib mocked out 170 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 171 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 172 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 173 | 174 | licenses(["notice"]) 175 | 176 | diff --git toolchains/node/BUILD.bazel toolchains/node/BUILD.bazel 177 | index 02a0559..0bd7022 100755 178 | --- toolchains/node/BUILD.bazel 179 | +++ toolchains/node/BUILD.bazel 180 | @@ -11,9 +11,7 @@ 181 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 182 | # See the License for the specific language governing permissions and 183 | # limitations under the License. 184 | -# bazel_skylib mocked out 185 | -# load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 186 | -load("@build_bazel_rules_nodejs//:index.bzl", bzl_library = "dummy_bzl_library") 187 | +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 188 | 189 | package(default_visibility = ["//visibility:private"]) 190 | 191 | -- 192 | -------------------------------------------------------------------------------- /tests/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Bazel Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_rules:test_rules.bzl", "file_test", "rule_test") 16 | 17 | package(default_visibility = ["//visibility:private"]) 18 | 19 | AUTOPREFIXER_OUTPUT = """body { 20 | font: 42px 'Comic Sans MS'; 21 | -webkit-box-flex: 42; 22 | -webkit-flex: 42 -42 auto; 23 | -ms-flex: 42 -42 auto; 24 | flex: 42 -42 auto; 25 | } 26 | """ 27 | 28 | file_test( 29 | name = "autoprefixer_test", 30 | content = AUTOPREFIXER_OUTPUT, 31 | file = "//examples/autoprefixer:style_processed.css", 32 | ) 33 | 34 | RTLCSS_OUTPUT = """body { 35 | direction: rtl; 36 | margin: 5px 25px 20px 10px; 37 | padding: 4px 16px 12px 8px; 38 | border-width: 1px 4px 3px 2px; 39 | } 40 | """ 41 | 42 | file_test( 43 | name = "rtlcss_test", 44 | content = RTLCSS_OUTPUT, 45 | file = "//examples/rtlcss:style_processed.css", 46 | ) 47 | 48 | CUSTOM_PLUGIN_OUTPUT = """@media screen and (max-width: $(sidebar.width)) { 49 | body { 50 | font: $(blog.title.font.size) 'Comic Sans MS'; 51 | flex: 42 -42 auto; 52 | } 53 | } 54 | """ 55 | 56 | file_test( 57 | name = "custom_plugin_test", 58 | content = CUSTOM_PLUGIN_OUTPUT, 59 | file = "//examples/custom_plugin:style_processed.css", 60 | ) 61 | 62 | file_test( 63 | name = "custom_plugin_ts_test", 64 | content = CUSTOM_PLUGIN_OUTPUT, 65 | file = "//examples/custom_plugin_ts:style_processed.css", 66 | ) 67 | 68 | DATA_ATTR_OUTPUT = """/* This goes at the beginning of the file. */ 69 | @media screen and (max-width: 10px) { 70 | body { 71 | font: 42px 'Comic Sans MS'; 72 | flex: 42 -42 auto; 73 | } 74 | } 75 | """ 76 | 77 | file_test( 78 | name = "data_attr_test", 79 | content = DATA_ATTR_OUTPUT, 80 | file = "//examples/data_attr:style_processed.css", 81 | ) 82 | 83 | file_test( 84 | name = "positional_data_attr_test", 85 | content = DATA_ATTR_OUTPUT, 86 | file = "//examples/positional_data_attr:style_processed.css", 87 | ) 88 | 89 | ADDITIONAL_OUTPUT = """# Found 4 unique selectors (of 6 total) 90 | 91 | - body (1 total) 92 | - .container (2 total) 93 | - .image.full-width (2 total) 94 | - .image (1 total)""" 95 | 96 | file_test( 97 | name = "additional_outputs_test", 98 | content = ADDITIONAL_OUTPUT, 99 | file = "//examples/additional_outputs:selectors.md", 100 | ) 101 | 102 | file_test( 103 | name = "sourcemap_css_test", 104 | file = "//examples/sourcemap:style_processed.css", 105 | regexp = "/\\*# sourceMappingURL=style_processed\\.css\\.map \\*/", 106 | ) 107 | 108 | # Test that not only is a source map generated, it points to the original Sass 109 | # file. 110 | file_test( 111 | name = "sourcemap_map_test", 112 | file = "//examples/sourcemap:style_processed.css.map", 113 | regexp = "style\\.scss", 114 | ) 115 | 116 | rule_test( 117 | name = "multi_binary_test", 118 | generates = [ 119 | "styles/examples/multi_binary/style1.css", 120 | "styles/examples/multi_binary/style2.css", 121 | ], 122 | rule = "//examples/multi_binary:styles", 123 | ) 124 | 125 | rule_test( 126 | name = "multi_sourcemap_test", 127 | generates = [ 128 | "styles/examples/multi_sourcemap/style1.css", 129 | "styles/examples/multi_sourcemap/style1.css.map", 130 | "styles/examples/multi_sourcemap/style2.css", 131 | "styles/examples/multi_sourcemap/style2.css.map", 132 | ], 133 | rule = "//examples/multi_sourcemap:styles", 134 | ) 135 | 136 | WRAPPER_OUTPUT = """body { 137 | padding: 42px 36px 38px 40px; 138 | } 139 | /*hello!*/ 140 | """ 141 | 142 | file_test( 143 | name = "wrapper_test", 144 | content = WRAPPER_OUTPUT, 145 | file = "//examples/wrapper:style_processed.css", 146 | ) 147 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": [ 5 | "es5", 6 | "es6", 7 | "es2015.collection", 8 | "es2015.iterable", 9 | "es2015.core", 10 | "dom" 11 | ], 12 | "types": [ 13 | "node" 14 | ], 15 | "target": "es2015", 16 | "strict": true 17 | }, 18 | "include": [ 19 | "examples/*.ts", 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@bazel/typescript@^2.0.0": 6 | version "2.0.0" 7 | resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-2.0.0.tgz#2ff5615f09c733cc681ba2ada92b11c356b694cd" 8 | integrity sha512-5FPkxULWIjAKLG5J1XvpXpY1/4IK39dAoWA/Hhg+16gXTES32fT8w42k96pb6BTaNnyBuYgIHBpELEAJ40OOAQ== 9 | dependencies: 10 | protobufjs "6.8.8" 11 | semver "5.6.0" 12 | source-map-support "0.5.9" 13 | tsutils "2.27.2" 14 | 15 | "@bazel/worker@^2.0.0": 16 | version "2.0.0" 17 | resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-2.0.0.tgz#904de1708198b68cf90f088b43d1a7eb0a9cc252" 18 | integrity sha512-YKlEbKOZ51QIngN5FKZAsT9xRoZfeQGsb1ZDUqn8G7GnfzMuqlqzKEXFU8D3RwEO5rwJ8d7zhYqEKBjA9XfA8Q== 19 | dependencies: 20 | protobufjs "6.8.8" 21 | 22 | "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": 23 | version "1.1.2" 24 | resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" 25 | integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78= 26 | 27 | "@protobufjs/base64@^1.1.2": 28 | version "1.1.2" 29 | resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" 30 | integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== 31 | 32 | "@protobufjs/codegen@^2.0.4": 33 | version "2.0.4" 34 | resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" 35 | integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== 36 | 37 | "@protobufjs/eventemitter@^1.1.0": 38 | version "1.1.0" 39 | resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" 40 | integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A= 41 | 42 | "@protobufjs/fetch@^1.1.0": 43 | version "1.1.0" 44 | resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" 45 | integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU= 46 | dependencies: 47 | "@protobufjs/aspromise" "^1.1.1" 48 | "@protobufjs/inquire" "^1.1.0" 49 | 50 | "@protobufjs/float@^1.0.2": 51 | version "1.0.2" 52 | resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" 53 | integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E= 54 | 55 | "@protobufjs/inquire@^1.1.0": 56 | version "1.1.0" 57 | resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" 58 | integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik= 59 | 60 | "@protobufjs/path@^1.1.2": 61 | version "1.1.2" 62 | resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" 63 | integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0= 64 | 65 | "@protobufjs/pool@^1.1.0": 66 | version "1.1.0" 67 | resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" 68 | integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q= 69 | 70 | "@protobufjs/utf8@^1.1.0": 71 | version "1.1.0" 72 | resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" 73 | integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= 74 | 75 | "@types/long@^4.0.0": 76 | version "4.0.0" 77 | resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef" 78 | integrity sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q== 79 | 80 | "@types/node@^10.1.0": 81 | version "10.17.5" 82 | resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.5.tgz#c1920150f7b90708a7d0f3add12a06bc9123c055" 83 | integrity sha512-RElZIr/7JreF1eY6oD5RF3kpmdcreuQPjg5ri4oQ5g9sq7YWU8HkfB3eH8GwAwxf5OaCh0VPi7r4N/yoTGelrA== 84 | 85 | "@types/node@^12.12.7": 86 | version "12.12.7" 87 | resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.7.tgz#01e4ea724d9e3bd50d90c11fd5980ba317d8fa11" 88 | integrity sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w== 89 | 90 | ansi-styles@^3.2.1: 91 | version "3.2.1" 92 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" 93 | integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== 94 | dependencies: 95 | color-convert "^1.9.0" 96 | 97 | autoprefixer@^9.8.6: 98 | version "9.8.8" 99 | resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.8.8.tgz#fd4bd4595385fa6f06599de749a4d5f7a474957a" 100 | integrity sha512-eM9d/swFopRt5gdJ7jrpCwgvEMIayITpojhkkSMRsFHYuH5bkSQ4p/9qTEHtmNudUZh22Tehu7I6CxAW0IXTKA== 101 | dependencies: 102 | browserslist "^4.12.0" 103 | caniuse-lite "^1.0.30001109" 104 | normalize-range "^0.1.2" 105 | num2fraction "^1.2.2" 106 | picocolors "^0.2.1" 107 | postcss "^7.0.32" 108 | postcss-value-parser "^4.1.0" 109 | 110 | browserslist@^4.12.0: 111 | version "4.20.2" 112 | resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" 113 | integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== 114 | dependencies: 115 | caniuse-lite "^1.0.30001317" 116 | electron-to-chromium "^1.4.84" 117 | escalade "^3.1.1" 118 | node-releases "^2.0.2" 119 | picocolors "^1.0.0" 120 | 121 | buffer-from@^1.0.0: 122 | version "1.1.1" 123 | resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" 124 | integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== 125 | 126 | caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001317: 127 | version "1.0.30001320" 128 | resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001320.tgz#8397391bec389b8ccce328636499b7284ee13285" 129 | integrity sha512-MWPzG54AGdo3nWx7zHZTefseM5Y1ccM7hlQKHRqJkPozUaw3hNbBTMmLn16GG2FUzjR13Cr3NPfhIieX5PzXDA== 130 | 131 | chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2: 132 | version "2.4.2" 133 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" 134 | integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== 135 | dependencies: 136 | ansi-styles "^3.2.1" 137 | escape-string-regexp "^1.0.5" 138 | supports-color "^5.3.0" 139 | 140 | color-convert@^1.9.0: 141 | version "1.9.0" 142 | resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a" 143 | dependencies: 144 | color-name "^1.1.1" 145 | 146 | color-name@^1.1.1: 147 | version "1.1.3" 148 | resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" 149 | 150 | colors@~0.6.0-1: 151 | version "0.6.2" 152 | resolved "https://registry.yarnpkg.com/colors/-/colors-0.6.2.tgz#2423fe6678ac0c5dae8852e5d0e5be08c997abcc" 153 | integrity sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w= 154 | 155 | commander@~2.1.0: 156 | version "2.1.0" 157 | resolved "https://registry.yarnpkg.com/commander/-/commander-2.1.0.tgz#d121bbae860d9992a3d517ba96f56588e47c6781" 158 | integrity sha1-0SG7roYNmZKj1Re6lvVliOR8Z4E= 159 | 160 | electron-to-chromium@^1.4.84: 161 | version "1.4.92" 162 | resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.92.tgz#88996e9aceb3a500710fd439abfa89b6cc1ac56c" 163 | integrity sha512-YAVbvQIcDE/IJ/vzDMjD484/hsRbFPW2qXJPaYTfOhtligmfYEYOep+5QojpaEU9kq6bMvNeC2aG7arYvTHYsA== 164 | 165 | escalade@^3.1.1: 166 | version "3.1.1" 167 | resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" 168 | integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== 169 | 170 | escape-string-regexp@^1.0.5: 171 | version "1.0.5" 172 | resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" 173 | 174 | findup@^0.1.5: 175 | version "0.1.5" 176 | resolved "https://registry.yarnpkg.com/findup/-/findup-0.1.5.tgz#8ad929a3393bac627957a7e5de4623b06b0e2ceb" 177 | integrity sha1-itkpozk7rGJ5V6fl3kYjsGsOLOs= 178 | dependencies: 179 | colors "~0.6.0-1" 180 | commander "~2.1.0" 181 | 182 | has-flag@^3.0.0: 183 | version "3.0.0" 184 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" 185 | integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= 186 | 187 | long@^4.0.0: 188 | version "4.0.0" 189 | resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" 190 | integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== 191 | 192 | minimist@0.0.8: 193 | version "0.0.8" 194 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" 195 | integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= 196 | 197 | minimist@1.2.6: 198 | version "1.2.6" 199 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" 200 | integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== 201 | 202 | mkdirp@^0.5.1: 203 | version "0.5.1" 204 | resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" 205 | integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= 206 | dependencies: 207 | minimist "0.0.8" 208 | 209 | node-releases@^2.0.2: 210 | version "2.0.2" 211 | resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" 212 | integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== 213 | 214 | normalize-range@^0.1.2: 215 | version "0.1.2" 216 | resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" 217 | 218 | num2fraction@^1.2.2: 219 | version "1.2.2" 220 | resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede" 221 | 222 | picocolors@^0.2.1: 223 | version "0.2.1" 224 | resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-0.2.1.tgz#570670f793646851d1ba135996962abad587859f" 225 | integrity sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA== 226 | 227 | picocolors@^1.0.0: 228 | version "1.0.0" 229 | resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" 230 | integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== 231 | 232 | postcss-value-parser@^4.1.0: 233 | version "4.2.0" 234 | resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" 235 | integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== 236 | 237 | postcss@^6.0.14: 238 | version "6.0.23" 239 | resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324" 240 | integrity sha512-soOk1h6J3VMTZtVeVpv15/Hpdl2cBLX3CAw4TAbkpTJiNPk9YP/zWcD1ND+xEtvyuuvKzbxliTOIyvkSeSJ6ag== 241 | dependencies: 242 | chalk "^2.4.1" 243 | source-map "^0.6.1" 244 | supports-color "^5.4.0" 245 | 246 | postcss@^7.0.32: 247 | version "7.0.39" 248 | resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.39.tgz#9624375d965630e2e1f2c02a935c82a59cb48309" 249 | integrity sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA== 250 | dependencies: 251 | picocolors "^0.2.1" 252 | source-map "^0.6.1" 253 | 254 | postcss@^7.0.7: 255 | version "7.0.36" 256 | resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.36.tgz#056f8cffa939662a8f5905950c07d5285644dfcb" 257 | integrity sha512-BebJSIUMwJHRH0HAQoxN4u1CN86glsrwsW0q7T+/m44eXOUAxSNdHRkNZPYz5vVUbg17hFgOQDE7fZk7li3pZw== 258 | dependencies: 259 | chalk "^2.4.2" 260 | source-map "^0.6.1" 261 | supports-color "^6.1.0" 262 | 263 | protobufjs@6.8.8: 264 | version "6.8.8" 265 | resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c" 266 | integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw== 267 | dependencies: 268 | "@protobufjs/aspromise" "^1.1.2" 269 | "@protobufjs/base64" "^1.1.2" 270 | "@protobufjs/codegen" "^2.0.4" 271 | "@protobufjs/eventemitter" "^1.1.0" 272 | "@protobufjs/fetch" "^1.1.0" 273 | "@protobufjs/float" "^1.0.2" 274 | "@protobufjs/inquire" "^1.1.0" 275 | "@protobufjs/path" "^1.1.2" 276 | "@protobufjs/pool" "^1.1.0" 277 | "@protobufjs/utf8" "^1.1.0" 278 | "@types/long" "^4.0.0" 279 | "@types/node" "^10.1.0" 280 | long "^4.0.0" 281 | 282 | rtlcss@^2.4.0: 283 | version "2.4.0" 284 | resolved "https://registry.yarnpkg.com/rtlcss/-/rtlcss-2.4.0.tgz#482ea28f2b9fe06dd0ab3057997be9af13da84c1" 285 | integrity sha512-hdjFhZ5FCI0ABOfyXOMOhBtwPWtANLCG7rOiOcRf+yi5eDdxmDjqBruWouEnwVdzfh/TWF6NNncIEsigOCFZOA== 286 | dependencies: 287 | chalk "^2.3.0" 288 | findup "^0.1.5" 289 | mkdirp "^0.5.1" 290 | postcss "^6.0.14" 291 | strip-json-comments "^2.0.0" 292 | 293 | semver@5.6.0: 294 | version "5.6.0" 295 | resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" 296 | integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== 297 | 298 | source-map-support@0.5.9: 299 | version "0.5.9" 300 | resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" 301 | integrity sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA== 302 | dependencies: 303 | buffer-from "^1.0.0" 304 | source-map "^0.6.0" 305 | 306 | source-map@^0.6.0, source-map@^0.6.1: 307 | version "0.6.1" 308 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" 309 | integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== 310 | 311 | strip-json-comments@^2.0.0: 312 | version "2.0.1" 313 | resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" 314 | integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= 315 | 316 | supports-color@^5.3.0, supports-color@^5.4.0: 317 | version "5.5.0" 318 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" 319 | integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== 320 | dependencies: 321 | has-flag "^3.0.0" 322 | 323 | supports-color@^6.1.0: 324 | version "6.1.0" 325 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" 326 | integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== 327 | dependencies: 328 | has-flag "^3.0.0" 329 | 330 | tslib@^1.8.1: 331 | version "1.10.0" 332 | resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" 333 | integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== 334 | 335 | tsutils@2.27.2: 336 | version "2.27.2" 337 | resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.2.tgz#60ba88a23d6f785ec4b89c6e8179cac9b431f1c7" 338 | integrity sha512-qf6rmT84TFMuxAKez2pIfR8UCai49iQsfB7YWVjV1bKpy/d0PWT5rEOSM6La9PiHZ0k1RRZQiwVdVJfQ3BPHgg== 339 | dependencies: 340 | tslib "^1.8.1" 341 | 342 | typescript@^3.7.2: 343 | version "3.7.2" 344 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb" 345 | integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ== 346 | --------------------------------------------------------------------------------