Last active
August 3, 2022 15:58
-
-
Save existentialmutt/a9a6b3d07f11e44a2b14ee60c6321fb9 to your computer and use it in GitHub Desktop.
Include JS from ruby gem with esbuild
This file contains hidden or 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
import "my-gem" |
This file contains hidden or 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
require("esbuild").build({ | |
//... | |
nodePaths: [process.env.NODE_PATH] | |
}).catch(() => process.exit(1)); |
This file contains hidden or 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
//... | |
"scripts": { | |
"build": "NODE_PATH=$(bundle show --paths my-gem)/app/javascript node esbuild.config.js" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Configuration for including javascript direct from a gem with esbuild as commonly found in Rail
To avoid ambiguity put the gem's js under a name-specific folder in app/javascript
e.g.