Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from bazelbuild/rtlcss
Browse files Browse the repository at this point in the history
Add RTLCSS build rule
  • Loading branch information
rzhw authored Nov 19, 2019
2 parents 1ae2899 + a6130bc commit 9e02be1
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 2 deletions.
2 changes: 2 additions & 0 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Users should not load files under "/internal"
load("//internal:plugin.bzl", _postcss_plugin = "postcss_plugin")
load("//internal:binary.bzl", _postcss_binary = "postcss_binary")
load("//internal/autoprefixer:build_defs.bzl", _autoprefixer = "autoprefixer")
load("//internal/rtlcss:build_defs.bzl", _rtlcss = "rtlcss")

postcss_plugin = _postcss_plugin
postcss_binary = _postcss_binary
autoprefixer = _autoprefixer
rtlcss = _rtlcss
23 changes: 23 additions & 0 deletions examples/rtlcss/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2019 The Bazel Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//:defs.bzl", "rtlcss")

package(default_visibility = ["//tests:__subpackages__"])

rtlcss(
name = "rtlcss",
src = "style.css",
out = "style_processed.css",
)
6 changes: 6 additions & 0 deletions examples/rtlcss/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
direction: ltr;
margin: 5px 10px 20px 25px;
padding: 4px 8px 12px 16px;
border-width: 1px 2px 3px 4px;
}
13 changes: 13 additions & 0 deletions internal/rtlcss/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019 The Bazel Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
44 changes: 44 additions & 0 deletions internal/rtlcss/build_defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2019 The Bazel Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Build rule for using rtlcss to postprocess CSS."""

load("//internal:binary.bzl", "postcss_binary")

def rtlcss(
name,
src,
out,
visibility = None):
"""Runs rtlcss on the given source files located in the given fileset.
Args:
name: A unique label for this rule.
src: Source file or target.
out: Output file.
visibility: The visibility of the build rule.
"""

postcss_binary(
name = name,
plugins = {
"rtlcss": "",
},
deps = [
"@npm//rtlcss",
],
src = src,
output_name = out,
visibility = visibility,
)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"autoprefixer": "9.4.3",
"minimist": "1.2.0",
"postcss": "7.0.7",
"rtlcss": "^2.4.0",
"typescript": "^3.7.2"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ file_test(
file = "//examples/autoprefixer:style_processed.css",
)

RTLCSS_OUTPUT = """body {
direction: rtl;
margin: 5px 25px 20px 10px;
padding: 4px 16px 12px 8px;
border-width: 1px 4px 3px 2px;
}
"""

file_test(
name = "rtlcss_test",
content = RTLCSS_OUTPUT,
file = "//examples/rtlcss:style_processed.css",
)

CUSTOM_PLUGIN_OUTPUT = """@media screen and (max-width: 42px) {
body {
font: 42px "Comic Sans MS";
Expand Down
59 changes: 57 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ caniuse-lite@^1.0.30000921, caniuse-lite@^1.0.30000989:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000999.tgz#427253a69ad7bea4aa8d8345687b8eec51ca0e43"
integrity sha512-1CUyKyecPeksKwXZvYw0tEoaMCo/RwBlXmEtN5vVnabvO0KPd9RQLcaAuR9/1F+KDMv6esmOFWlsXuzDk+8rxg==

chalk@^2.4.1, chalk@^2.4.2:
chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
Expand All @@ -137,6 +137,16 @@ color-name@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"

colors@~0.6.0-1:
version "0.6.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-0.6.2.tgz#2423fe6678ac0c5dae8852e5d0e5be08c997abcc"
integrity sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=

commander@~2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.1.0.tgz#d121bbae860d9992a3d517ba96f56588e47c6781"
integrity sha1-0SG7roYNmZKj1Re6lvVliOR8Z4E=

electron-to-chromium@^1.3.247:
version "1.3.280"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.280.tgz#5f8950c8329e3e11b59c705fd59b4b8d9b3de5b9"
Expand All @@ -146,6 +156,14 @@ escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"

findup@^0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/findup/-/findup-0.1.5.tgz#8ad929a3393bac627957a7e5de4623b06b0e2ceb"
integrity sha1-itkpozk7rGJ5V6fl3kYjsGsOLOs=
dependencies:
colors "~0.6.0-1"
commander "~2.1.0"

has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
Expand All @@ -156,10 +174,22 @@ long@^4.0.0:
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==

minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=

minimist@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

mkdirp@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
dependencies:
minimist "0.0.8"

node-releases@^1.1.29:
version "1.1.35"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.35.tgz#32a74a3cd497aa77f23d509f483475fd160e4c48"
Expand Down Expand Up @@ -189,6 +219,15 @@ postcss@7.0.7:
source-map "^0.6.1"
supports-color "^5.5.0"

postcss@^6.0.14:
version "6.0.23"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324"
integrity sha512-soOk1h6J3VMTZtVeVpv15/Hpdl2cBLX3CAw4TAbkpTJiNPk9YP/zWcD1ND+xEtvyuuvKzbxliTOIyvkSeSJ6ag==
dependencies:
chalk "^2.4.1"
source-map "^0.6.1"
supports-color "^5.4.0"

postcss@^7.0.6:
version "7.0.18"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.18.tgz#4b9cda95ae6c069c67a4d933029eddd4838ac233"
Expand Down Expand Up @@ -217,6 +256,17 @@ protobufjs@6.8.8:
"@types/node" "^10.1.0"
long "^4.0.0"

rtlcss@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/rtlcss/-/rtlcss-2.4.0.tgz#482ea28f2b9fe06dd0ab3057997be9af13da84c1"
integrity sha512-hdjFhZ5FCI0ABOfyXOMOhBtwPWtANLCG7rOiOcRf+yi5eDdxmDjqBruWouEnwVdzfh/TWF6NNncIEsigOCFZOA==
dependencies:
chalk "^2.3.0"
findup "^0.1.5"
mkdirp "^0.5.1"
postcss "^6.0.14"
strip-json-comments "^2.0.0"

semver@5.6.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
Expand All @@ -240,7 +290,12 @@ source-map@^0.6.0, source-map@^0.6.1:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

supports-color@^5.3.0, supports-color@^5.5.0:
strip-json-comments@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

supports-color@^5.3.0, supports-color@^5.4.0, supports-color@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
Expand Down

0 comments on commit 9e02be1

Please sign in to comment.