Question
I've got a site using Laravel Mix, and am coming from a misterbk/mix
plugin setup. Due to the site spanning various load-balanced servers, I need to have root-relative URLs, instead of absolute domain URLs. I've got it working just fine locally (using ddev under Windows), but I can't for the life of me get it to work on the remote server.
Relevant paths:
Manifest: @webroot/mix-manifest.json
CSS: @webroot/assets/css/all.css
JS: @webroot/assets/js/app.css
mix-manifest.json has:
{
"/assets/js/app.js": "/assets/js/app.js?id=b1341a8e6d5d440d33f67925d0e0d5d1",
"/assets/css/all.css": "/assets/css/all.css?id=a0089034478a1be737d8cf5ad8f6f704",
}
My layout template is referring to the above files like so:
<link rel="stylesheet" href="{{ craft.twigpack.getModuleUri('/assets/css/all.css') }}" title="All styles">
...
<script src="{{ craft.twigpack.getModuleUri('/assets/js/app.js') }}" defer></script>
Finally, my config/twigpack.php
in its entirety:
<?php
return [
// Global settings
'*' => [
// If `devMode` is on, use webpack-dev-server to all for HMR (hot module reloading)
'useDevServer' => false,
// Enforce Absolute URLs on includes
'useAbsoluteUrl' => false,
// The JavaScript entry from the manifest.json to inject on Twig error pages
// This can be a string or an array of strings
'errorEntry' => '',
// String to be appended to the cache key
'cacheKeySuffix' => '',
// Manifest file names
'manifest' => [
'legacy' => 'mix-manifest.json',
'modern' => 'mix-manifest.json',
],
// Public server config
'server' => [
'manifestPath' => '@webroot/',
'publicPath' => '/',
],
// webpack-dev-server config
'devServer' => [
'manifestPath' => '@webroot/',
'publicPath' => '/',
],
// Bundle to use with the webpack-dev-server
'devServerBuildType' => 'modern',
// Whether to include a Content Security Policy "nonce" for inline
// CSS or JavaScript. Valid values are 'header' or 'tag' for how the CSP
// should be included. c.f.:
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script
'cspNonce' => '',
// Local files config
'localFiles' => [
'basePath' => '@webroot/',
'criticalPrefix' => 'dist/criticalcss/',
'criticalSuffix' => '_critical.min.css',
],
],
// Development environment
'dev' => [
// If `devMode` is on, use webpack-dev-server to all for HMR (hot module reloading)
'useDevServer' => true,
],
// Staging (pre-production) environment
'staging' => [
],
// Live (production) environment
'production' => [
],
];
Now, when I load the site in that state, there's no output from the {{ craft.twigpack.getModuleUri() }}
tags, and the web.log
shows:
2022-07-28 14:22:10 [-][123042][-][error][nystudio107\twigpack\helpers\Manifest::reportError] Manifest file not found at: @webroot/assets/
Now, uhh, it's probably worth noting at this point that I used to have things set up in the recent past to use a mix-manifest.json
located at @webroot/assets/mix-manifest.json
(and in all honesty, I can go back to using it there if it makes any difference). However, as you can see, I have excised all references that I can find to that being the path, and yet somehow, Twigpack still thinks that mix-manifest is located under @webroot/assets/
. 🤨
And yes, I have cleared the Twigpack Manifest cache (as well as all the other ones that don't have to do with image transforms), to no avail.
Any pointers? 🆘 What am I missing?