Copy flot file to vendor directory

This commit is contained in:
Henrik Giesel 2020-12-29 12:11:28 +01:00
parent 6aad58260b
commit ef9b52f861
2 changed files with 36 additions and 0 deletions

View File

@ -1,13 +1,20 @@
load("//ts:jquery.bzl", "copy_jquery")
load("//ts:flot.bzl", "copy_flot")
copy_jquery(
name = "jquery",
visibility = ["//visibility:public"],
)
copy_flot(
name = "flot",
visibility = ["//visibility:public"],
)
files = [
"jquery",
"flot",
]
directories = [

29
ts/flot.bzl Normal file
View File

@ -0,0 +1,29 @@
load("//ts:copy.bzl", "copy_files")
"Rule to copy flot subset from node_modules to vendor folder."
_include = [
"dist/es5/jquery.flot.js",
]
_unwanted_prefix = "external/npm/node_modules/flot/dist/es5/"
def _copy_flot_impl(ctx):
wanted = []
for f in ctx.attr.flot.files.to_list():
path = f.path
want = True
for substr in _include:
if substr in path:
output = path.replace(_unwanted_prefix, "")
wanted.append((f, output))
return copy_files(ctx, wanted)
copy_flot = rule(
implementation = _copy_flot_impl,
attrs = {
"flot": attr.label(default = "@npm//flot:flot__files"),
},
)