-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build: create sass_bundle bazel rule #10055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
07dcd6a
to
95dce88
Compare
|
||
sass_bundle( | ||
name = "theming_bundle", | ||
srcs = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
introduce a constant in the top-level BUILD file?
ALL_LIBS=["autocomplete", "badge]
then here it's just
srcs = ["//src/lib/%s:%s_scss_partials" % l for l in ALL_LIBS]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a .bzl
file at the top-level with a constant for this. I didn't think it was possible to import a constant from another BUILD
file. Am I missing something?
@@ -21,6 +21,11 @@ ng_module( | |||
tsconfig = ":tsconfig-build.json", | |||
) | |||
|
|||
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could make a simple PR to rules_sass to get this process started, at least test the waters to see if anyone is maintaining it, if they offer to hand over the keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add it to my general "Making sass better" task list
@@ -0,0 +1,22 @@ | |||
package(default_visibility=["//visibility:public"]) | |||
load("@angular//:index.bzl", "ng_module") | |||
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library", "sass_binary") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to hook up skylint to tell you about unused imports and such
and buildifier too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the tasks I have tracked in #8369
const parsedArgs: {srcs: string, output: string, entry: string} = minimist(args); | ||
const inputFiles = parsedArgs.srcs.split(','); | ||
|
||
return new Bundler().Bundle(join(workspaceRoot, parsedArgs.entry), inputFiles).then(result => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you determine if the CLI in scss-bundle is not suitable? if so, comment why in the fileoverview here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't get the nodejs_binary
to work with the package's existing CLI and it was less work to keep this. It's also easier to debug the calls from bazel this way. Added a comment.
tools/sass_bundle.ts
Outdated
@@ -0,0 +1,29 @@ | |||
import {dirname, join} from 'path'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you need license headers in this repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I knew we only needed license headers for code synced into google.
tools/sass_bundle.bzl
Outdated
# rule (and will thus be available to the nodejs_binary in the sandbox). | ||
"entry_point": attr.label(mandatory = True, allow_single_file = True), | ||
|
||
# The executable (bundler) for this rule. The user will typically never |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you start with underscore, users won't be able to set it - I'd recommend keeping as much API private as possible until you understand why someone wants to set this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. (I didn't know you could do that)
@@ -0,0 +1,8 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sadness, why another tsconfig file? the editor won't know about these settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default bazel one doesn't have types: node
and lib: es2015
. I removed the other two options.
tools/bazel-tools-tsconfig.json
Outdated
@@ -0,0 +1,8 @@ | |||
{ | |||
"compilerOptions": { | |||
"module": "commonjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should give you a warning (if your rules_typescript is recent)
--module is controlled by Bazel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
tools/bazel-tools-tsconfig.json
Outdated
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@@ -22,6 +17,17 @@ ng_module( | |||
tsconfig = ":tsconfig-build.json", | |||
) | |||
|
|||
# TODO(jelbourn): remove this when sass_library acts like a filegroup | |||
filegroup( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we're in the business of making our own bazel rules, should we just replace these two rules with something like material_sass_library
? or maybe go even further and extract all of the rules shared by every component into some sort of material_module
rule?
material_module(
name = "button",
module_name = "@angular/material/button",
srcs = [...],
deps = [...],
scss = [...],
theme_scss = [...],
templates = [...]
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning on putting some time into either fixing or replacing the open source sass rules so that they match the ones in Google. These don't change often, so it shouldn't hurt our productivity to leave it until we can get the ecosystem sorted out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we should try to make the primitives work instead of wrapping them in macros, which are leaky abstractions.
BUILD.bazel
Outdated
@@ -46,6 +46,43 @@ ANGULAR_TESTING = [ | |||
"node_modules/@angular/platform-browser-dynamic/bundles/*.umd.js", | |||
] | |||
|
|||
MATERIAL_COMPONENTS = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget to remove this copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
7dffd4f
to
3264ce9
Compare
This defines a bazel rule to bundle sass partials into a single file using the "scss-bundle" npm package. The rule definition is commented so that it can serve as an example for creating other rules in the future. I've also added the missing build file for badge so that its theme can be included in the bundle.
3264ce9
to
f06c51c
Compare
f06c51c
to
f20aa37
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This defines a bazel rule to bundle sass partials into a single file
using the "sass-bundle" npm package. The rule definition is commented so
that it can serve as an example for creating other rules in the future.
I've also added the missing build file for badge so that its theme can
be included in the bundle.
I probably should have split this up into three PRs but, well, here we are.
cc fyi @devversion