Currently we are running a Sage 10 + Acorn setup but without Bud and still Webpack instead, since we work on Windows. Now we are updating our theme and want to migrate to Vite, however when we try to use the Vite class provided by Laravel, we get errors about mixing strings with arrays and/or an Acorn Asset class. In acorn/src/Roots/Acorn/Assets we can see a Vite class extending the Laravel class to return the Roots asset uri, however we can’t get it to work. What would be the correct way to integrate Vite with Acorn (and Sage 10)?
So the main thing I was looking for was: app(assets.vite)
. However now when I invoke that class, I get the tags directly as they are in my manifest.json
file, such as assets/app-xEeG6hAt.js
. However since it’s a wordpress theme the source of the tag needs to be: <HOST>/wp-content/themes/<theme-name>/assets/app-xEeG6hAt.js
. How can I use the Vite class to get the tags with the correct directories?
So to fix the previous issue I extended the Acorn Vite class with my own and overwrite the asset()
function, currently I use:
parse_url(get_stylesheet_directory_uri(), PHP_URL_PATH) . '/public'
to add /wp-content/themes/<theme-name>/public
, is there a more elegant way?