Skip to content

Commit

Permalink
Adds image resource to external example.
Browse files Browse the repository at this point in the history
Refs #48.

This just worked without any issues. Technically `prerender_pages()` emits a `WebResources` provider and follows the same code path, so this really has been working for a while now.
  • Loading branch information
dgp1130 committed Feb 11, 2023
1 parent ffb736a commit cb9b2b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion examples/external/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm_user//:defs.bzl", "npm_link_all_packages")
load("@rules_prerender//:index.bzl", "css_library", "prerender_pages", "web_resources_devserver")
load(
"@rules_prerender//:index.bzl",
"css_library",
"prerender_pages",
"web_resources",
"web_resources_devserver",
)

npm_link_all_packages(name = "node_modules")

Expand All @@ -18,6 +24,7 @@ prerender_pages(
src = "site.ts",
scripts = [":script"],
styles = [":styles"],
resources = [":resources"],
source_map = True, # TODO(#48): This doesn't seem to work?
tsconfig = "//:tsconfig.json",
lib_deps = ["//:node_modules/rules_prerender"],
Expand All @@ -35,6 +42,13 @@ css_library(
srcs = ["style.css"],
)

web_resources(
name = "resources",
entries = {
"/logo": "logo.png",
},
)

web_resources_devserver(
name = "devserver",
resources = ":site",
Expand Down
Binary file added examples/external/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions examples/external/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default function*(): Generator<PrerenderResource, void, void> {
</head>
<body>
<h2>Hello, World!</h2>
<img src="/logo">
${includeScript('script.js')}
${inlineStyle('external/style.css')}
</body>
Expand Down

0 comments on commit cb9b2b5

Please sign in to comment.