Created
August 7, 2025 14:51
-
-
Save tcannonfodder/4a2e23f9625a17c7ea524998456b62dc to your computer and use it in GitHub Desktop.
Web Awesome + Bundled CSS + Autoloader support + Rails + Rollup
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
| <%= javascript_include_tag "webawesome", type: :module, defer: true, data: {webawesome: '/assets/webawesome-dist'} %> |
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
| // This is just a snapship of the build file, with the functions specific to this approach | |
| port * as esbuild from 'esbuild'; | |
| const webAwesomePublicDirectory = path.join(process.cwd(), "public/assets/webawesome-dist") | |
| function copyFiles(from, to, overwrite = false) { | |
| return { | |
| name: 'copy-files', | |
| generateBundle() { | |
| const resolvedFrom = path.resolve(from) | |
| const resolvedTo = path.resolve(to) | |
| console.log(`copy files: ${resolvedFrom} → ${resolvedTo}`) | |
| fs.mkdirSync(resolvedTo, { recursive: true }) | |
| fs.cpSync(resolvedFrom, resolvedTo, {recursive: true}) | |
| } | |
| } | |
| } | |
| const buildEntrypoints = async () => { | |
| /// | |
| const webawesomeCSSPath = path.join(process.cwd(), "app/assets/stylesheets/", "webawesome.esbuild.css") | |
| await esbuild.build({ | |
| entryPoints: [webawesomeCSSPath], | |
| bundle: true, | |
| outfile: "app/assets/builds/webawesome.css", | |
| }) | |
| var outputPlugins = [ | |
| //... | |
| copyFiles("./node_modules/webawesome/dist", webAwesomePublicDirectory), | |
| ] | |
| } |
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
| // Adding `webawesome` as a depencency via a vendorized package | |
| "webawesome": "file:./vendor/webawesome-zip" |
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 url('webawesome/dist/styles/webawesome.css') layer(framework.wa); | |
| @import url('webawesome/dist/styles/themes/glossy.css') layer(framework.wa); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment