This little plugin reads the Mix Manifest that is generated by the standalone version of Laravel Mix.
In order to use this plugin you will need set up Laravel Mix (duh!) and enable the versioning in the webpack.mix.js
.
This plugin depends on several config fields, which should be set correctly. Most of the properties should already be correct when left default, but you should definetely set your app url correctly. You can find this property in the config/app.php
file.
The next step is set up your env
file and add the MANIFEST_PATH
field to your env
file. This entry needs to points directly to the manifest file in your project.
After installing this plugin you can call mix()
in Twig. This function takes one parameter which should be the relative path to the file from inside your assets
folder.
<link rel="stylesheet" href="{{ mix('/dist/app.css') }}">
Without a second parameter the mix
function assumes that your relative path starts at themes/{themename}/assets
. If your assets are located elsewhere you can pass a second parameter to the function which replaces the standard "/assets"
path prefix.
Note: The /
before the actual path is required for this to work
<link rel="stylesheet" href="{{ mix('/dist/app.css' , '/my-assets-path') }}">
In previous versions the mix
function was called getVersionedCss
. To prevent breaking changes this still works, but the new mix
method is favored of the old getVersionedCss
.
This plugin is based on a front-end workflow based on Jeffrey Way's standalone Laravel Mix that can be found here. An example of a package.json
and webpack.mix.js
are also present in this repository. Further documentation on how to use Laravel Mix can be found in the docs of Laravel Mix.
While there isn't much to license, we'd appreciate it if you do not sell the plugin or the code in it as your own, either under a new name or as part of your own plugin.