Webpack hashed files in October CMS

Installs: 3 448

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 10

Forks: 0

Open Issues: 1


2.0.2 2021-05-10 18:50 UTC

This package is not auto-updated.

Last update: 2021-06-12 10:26:20 UTC


This plugin for OctoberCMS works in tandem with the node package webpack-assets-manifest ( to include CSS, JS, and font assets in your site based on a JSON manifest file written to your assets directory. This will allow you to use hashed file names in your built files, and let October pick up the paths effortlessly.

In non-development environments (when the APP_ENV environment variable doesn't equal "dev") these paths get cached so the JSON file isn't read on every request. This cache should be cleared as a part of the deploy process by running php artisan cache:clear.


composer require castiron/webpackassets-plugin

Quick start

This plugin provides a component called webpackAssets. Include the component in your view and then use the following to include the js/css/fonts (WOFF2 only) in your template (e.g. in a partial, layout, etc.):


<!-- include font <link rel="preload"> tags: -->
{{ webpackAssets.tag('unhashed_filename.woff2') | raw }}

<!-- include css <link> tags: -->
{{ webpackAssets.tag('unhashed_filename.css') | raw }}

<!-- include js <script> tags: -->
{{ webpackAssets.tag('unhashed_filename.js') | raw }}
{{ webpackAssets.tag('webpack-dev-server.js') | raw }}

Keep in mind that there’s a performance trade-off to preloading too many font assets, so limit your use to only the highest-priority font assets. For the same reason, the plugin will only create tags for the WOFF2 font format. (See “The Critical Request” and “The Web Fonts: Preloaded” for more information.)

Component options

publicFolder (default: "www")

If you are using a public folder in OctoberCMS (you should be!), specify it here. E.g. "www" or "public"

publicFolder = public

assetsFolder (default: "assets")

The path to the folder, relative to your public folder, to which webpack is writing your assets. This corresponds to output.path from your webpack config.

assetsFolder = assets

manifestFilename (default: "manifest.json", must be relative to assetsFolder)

manifestFilename = files.json