From dbe5d43ba0f1d4e7a2fbe486889e1afbcfcfc84e Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 21 Mar 2021 15:45:15 +1000 Subject: [PATCH] bundle all Svelte css into separate file - svelte compilation outputs a separate .css file for each component - compilation also adds an "import foo.css" to the top of each generated .mjs file - when the .mjs files are bundled into app.js, esbuild creates an app.css as well - graphs.scss was renamed to graphs_shared.scss and imported in the top level GraphsPage. Henrik's style refactoring would be a better path forward, but I needed to make this change for now, as the filenames were conflicting. --- ts/esbuild.bzl | 2 +- ts/graphs/BUILD.bazel | 6 ++++-- ts/graphs/GraphsPage.svelte | 4 +--- ts/graphs/{graphs.scss => graphs_shared.scss} | 0 ts/svelte/BUILD.bazel | 1 + ts/svelte/svelte.ts | 14 +++++++++----- 6 files changed, 16 insertions(+), 11 deletions(-) rename ts/graphs/{graphs.scss => graphs_shared.scss} (100%) diff --git a/ts/esbuild.bzl b/ts/esbuild.bzl index f878bba06..e0c3021b7 100644 --- a/ts/esbuild.bzl +++ b/ts/esbuild.bzl @@ -1,4 +1,4 @@ -load("@npm//@bazel/esbuild:index.bzl", _esbuild = "esbuild") +load("//ts/esbuild:upstream.bzl", _esbuild = "esbuild_macro") def esbuild(name, **kwargs): _esbuild( diff --git a/ts/graphs/BUILD.bazel b/ts/graphs/BUILD.bazel index dfa909eb7..f33764193 100644 --- a/ts/graphs/BUILD.bazel +++ b/ts/graphs/BUILD.bazel @@ -6,8 +6,8 @@ load("//ts:esbuild.bzl", "esbuild") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") sass_binary( - name = "graphs_css", - src = "graphs.scss", + name = "graphs_shared", + src = "graphs_shared.scss", visibility = ["//visibility:public"], deps = [ "//ts/sass:core_lib", @@ -66,12 +66,14 @@ esbuild( external = [ "protobufjs/light", ], + output_css = True, visibility = ["//visibility:public"], deps = [ "//ts/lib", "//ts/lib:backend_proto", "//ts/lib:fluent_proto", "bootstrap", + "graphs_shared", ] + svelte_names, ) diff --git a/ts/graphs/GraphsPage.svelte b/ts/graphs/GraphsPage.svelte index 05ade8f0b..b7eab4172 100644 --- a/ts/graphs/GraphsPage.svelte +++ b/ts/graphs/GraphsPage.svelte @@ -1,7 +1,5 @@ - -