Skip to content
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

Support multiple entrypoints #6

Merged
merged 1 commit into from
Apr 28, 2023
Merged

Support multiple entrypoints #6

merged 1 commit into from
Apr 28, 2023

Conversation

jodosha
Copy link
Member

@jodosha jodosha commented Apr 28, 2023

Features

Multiple Entrypoints

Support multiple entrypoints in a Hanami application.
This feature is meant to split the js/css bundles in a way that makes sense for the user application.

Example: If the user wants a login page that doesn't have all the other js/css bundles, they can create an app/assets/javascripts/login/app.js, and Hanami::Assets will bundle it separately as public/assets/login/app-abc123.js.

Stylesheet importing

Import stylesheets by using the @import directive.

Example: From app.css, a user can import reset.css like this: @import 'reset.css'.

Import images from stylesheets

If an image is referenced from a stylesheet, it will be bundled in the destination directory.

Example:

Given a background image, located at app/assets/images/background.jpg, and a stylesheet like the following app/assets/stylesheets/app.css.

body {
  background-image: url('../images/background.jpg');
  # ...
}

Hanami::Assets will bundle the image at: public/assets/background-UU2XY655.jpg and rewrite the background image path of the destination CSS (public/assets/app-X3IVBUS4.css):

body {
  background-image: url('/assets/background-UU2XY655.jpg');
  # ...
}

The image will be part of the Assets Manifest, and Hanami::Assets will calculate the Subresource Integrity (if enabled).

Implementation

The app will recursively search for app.{js,ts,mjs,mts,tsx,jsx} in app/assets/javascripts and slices/*/assets/javascripts.
The matched files will constitute esbuild entrypoints.

@jodosha jodosha self-assigned this Apr 28, 2023
@jodosha jodosha merged commit 4e517a2 into main Apr 28, 2023
@jodosha jodosha deleted the multiple-entrypoints branch April 28, 2023 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant