Skip to content

Commit

Permalink
feat(less): new less package
Browse files Browse the repository at this point in the history
  • Loading branch information
joshvanallen authored and alexeagle committed Aug 17, 2019
1 parent b0c3178 commit 462f6e9
Show file tree
Hide file tree
Showing 31 changed files with 1,286 additions and 426 deletions.
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ k8s_defaults(
"karma",
"karma_stack_trace",
"karma_typescript",
"less",
"node_loader_no_preserve_symlinks",
"node_loader_preserve_symlinks",
"packages",
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
'jasmine',
'karma',
'labs',
'less',
'protractor',
'stylus',
'rollup',
Expand Down
1 change: 1 addition & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ _PACKAGE_READMES = {
"Built-ins": ":builtins.doc",
"Jasmine": "//packages/jasmine:README.md",
"Karma": "//packages/karma:README.md",
"Less": "//packages/less:README.md",
"Protractor": "//packages/protractor:README.md",
"Stylus": "//packages/stylus:README.md",
"TypeScript": "//packages/typescript:README.md",
Expand Down
3 changes: 3 additions & 0 deletions e2e/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ E2E_TESTS = {
"//packages/karma:npm_package": "@bazel/karma",
"//packages/typescript:npm_package": "@bazel/typescript",
},
"e2e_less": {
"//packages/less:npm_package": "@bazel/less",
},
"e2e_node_loader_no_preserve_symlinks": {
},
"e2e_node_loader_preserve_symlinks": {
Expand Down
1 change: 1 addition & 0 deletions e2e/less/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import %workspace%/../../common.bazelrc
31 changes: 31 additions & 0 deletions e2e/less/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_test")
load("@npm_bazel_less//:index.bzl", "less_binary")

less_binary(
name = "styles",
src = "test.less",
)

nodejs_test(
name = "test",
data = [
"golden.css",
"test.js",
":styles",
],
entry_point = ":test.js",
)

# For testing from the root workspace of this repository with bazel_integration_test.
filegroup(
name = "all_files",
srcs = glob(
include = ["**/*"],
exclude = [
"bazel-out/**/*",
"dist/**/*",
"node_modules/**/*",
],
),
visibility = ["//visibility:public"],
)
38 changes: 38 additions & 0 deletions e2e/less/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2018 The Bazel Authors. All rights reserved.
#
# 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
#
# http://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.

workspace(
name = "e2e_less",
managed_directories = {"@npm": ["node_modules"]},
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "6625259f9f77ef90d795d20df1d0385d9b3ce63b6619325f702b6358abb4ab33",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.35.0/rules_nodejs-0.35.0.tar.gz"],
)

load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")

yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)

load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()
7 changes: 7 additions & 0 deletions e2e/less/golden.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions e2e/less/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "e2e-less",
"private": true,
"devDependencies": {
"@bazel/less": "file:../../dist/bin/packages/less/npm_package"
},
"scripts": {
"test": "bazel test ..."
}
}
7 changes: 7 additions & 0 deletions e2e/less/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const fs = require('fs');
const expected = fs.readFileSync(require.resolve('e2e_less/golden.css'), 'utf-8');
const actual = fs.readFileSync(require.resolve('e2e_less/test.css'), 'utf-8');
if (expected !== actual) {
console.error(`FAILED. Expected\n${expected}\n but was\n${actual}`);
process.exitCode = 1;
}
6 changes: 6 additions & 0 deletions e2e/less/test.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
font: 14px/1.5 Helvetica, arial, sans-serif;
#logo {
border-radius: 5px;
}
}
Loading

0 comments on commit 462f6e9

Please sign in to comment.