Course Overview
Locked video preview

Paid video

Please purchase the course to watch.

Making things pretty and responsive

Embedding assets

Here is a summary of the video transcript:

  • Serving CSS in a Go Application
    The video explains different ways to serve a CSS file, including hosting it on a server, using S3 with a CDN, or embedding it directly into the Go binary. The chosen approach uses Go’s embed package to bundle static files into a single compiled binary for simpler deployment.

  • Compiling Tailwind CSS with the Standalone CLI
    Tailwind’s standalone binary is downloaded and configured to scan the views directory for class usage. It generates a compiled CSS file that is later embedded into the Go binary.

  • Project Structure and Embedding Assets
    An assets directory is created along with an assets.go file to embed static files using embed.FS. The compiled style.css file is placed in this directory and included in the final binary.

  • Controller and Route for Serving Styles
    A new controller reads the embedded style.css file and serves it with the correct text/css content type. A route with an /assets prefix is defined and connected to the controller, allowing the stylesheet to be requested by the browser.

  • Linking the Stylesheet in the Layout
    The base layout is updated with a <link> tag referencing the new stylesheet route. This enables the browser to fetch and apply the compiled CSS.

  • Development and Production CSS Builds
    Two build commands are defined: one with a watch flag for development and another minified version for production. The development command recompiles CSS automatically on changes, while the production build optimizes file size.

  • Verification and Next Steps
    After running the application, Tailwind’s base reset styles are confirmed to be applied in the browser. The next steps will focus on responsive design and theming to enhance the application’s visual appearance.