External assets
When referencing external modules, the files for the asset folder should be somehow shippable. This is a proposal for a simple helper function that copies the files to the assets folder of the app that is currently compiled.
# library_module.index.py
# In the library module reference the
# asset files with the relative file path to the including script.
@rx.page("/")
def index() -> rx.Component:
return rx.center(
rx.image(src=rx.asset("test.png",dir="subfolder"))
)
During compilation those files are copied to assets/external/library_module/index/subfolder/test.png.
In case you want to make assets from your library includable for calling modules, you can expose them like this:
class Assets:
test_png = rx.asset("test.png", "hang_it_up")
script_js = rx.asset("my_component_logic.js")
@abulvenz how about symlinking instead of copying?
Edit: Not sure how symlinks behave on Windows
@abulvenz how about symlinking instead of copying? Edit: Not sure how symlinks behave on Windows
Symlink doesn't work on Windows, we had this in the beginning for syncing between assets and .web/public folder, but had to remove it for Windows.
Symlink doesn't work on Windows, we had this in the beginning for syncing between
assetsand.web/publicfolder, but had to remove it for Windows.
@Lendemor Should I change it back? :mechanic:
Is anything else missing here?
@Lendemor Is it possible that I cancelled your approval by merging main? Sorry. :bowl_with_spoon: