Skip to content

Instantly share code, notes, and snippets.

@tcannonfodder
Created August 7, 2025 14:51
Show Gist options
  • Select an option

  • Save tcannonfodder/4a2e23f9625a17c7ea524998456b62dc to your computer and use it in GitHub Desktop.

Select an option

Save tcannonfodder/4a2e23f9625a17c7ea524998456b62dc to your computer and use it in GitHub Desktop.
Web Awesome + Bundled CSS + Autoloader support + Rails + Rollup
<%= javascript_include_tag "webawesome", type: :module, defer: true, data: {webawesome: '/assets/webawesome-dist'} %>
// 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),
]
}
// Adding `webawesome` as a depencency via a vendorized package
"webawesome": "file:./vendor/webawesome-zip"
@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