-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile within single slice only (#20)
Update our esbuild wrapper to compile a single assets directory at a time. Previously, we crawled the entire app structure to find all assets directories (within the app and slices) and processed them all at once. This had some downsides: - It made our esbuild wrapper and plugin complicated. - It meant that we had to take extra steps to prevent naming conflicts for assets with the same name in different slices. - The above also meant that every slice's assets had to be referred to with the slice name as a leading namespace (e.g. "admin/app.js" for an admin slice), which didn't fit well with the idea of slices being fully self-contained. - In general, it meant we had redundant functionality in JS code (such as locating slices) that already existed in our Ruby code. By processing a single assets directory at once, we have a much simpler interface with esbuild: we're not pushing it to do things outside its comfort zone. It also means we can eliminate that redundant logic and continue to leverage our Ruby code as the canonical source of knowledge around slices and the overall Hanami app structure. To process a single directory and output the compiled files into the relevant location, we expect these to be passed as two new arguments when invoking `config/assets.js`: - `--path`: the path for the app or slice containing the assets to process; e.g. `app` or `slices/admin` - `--dest`: the directory to putout the compiled files; e.g. `public/assets` or `public/assets/admin` (in the case of the admin slice) These args will not need to be supplied by the user. Instead, they'll be provided by the `hanami assets compile` and `hanami assets watch` commands, which will determine the slices with assets and then invoke one `config/assets.js` process per slice, along with the relevant CLI arguments. This means the user experience is still simple and streamlined.
- Loading branch information
Showing
12 changed files
with
372 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export interface Args { | ||
path: string; | ||
dest: string; | ||
watch: Boolean; | ||
sri: string[] | null; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { Plugin } from "esbuild"; | ||
export interface PluginOptions { | ||
root: string; | ||
publicDir: string; | ||
sourceDir: string; | ||
destDir: string; | ||
manifestPath: string; | ||
sriAlgorithms: Array<string>; | ||
hash: boolean; | ||
} | ||
export declare const defaults: Pick<PluginOptions, "root" | "publicDir" | "destDir" | "manifestPath" | "sriAlgorithms" | "hash">; | ||
declare const hanamiEsbuild: (options?: PluginOptions) => Plugin; | ||
export declare const defaults: Pick<PluginOptions, "sriAlgorithms" | "hash">; | ||
declare const hanamiEsbuild: (options: PluginOptions) => Plugin; | ||
export default hanamiEsbuild; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.