Closed denisbertrandbe closed 12 months ago
Sounds good! Do you want to create a PR? Otherwise I could look into it later this week
I will create a push request soon ;-)
Thank you !
Denis On 20 Feb 2023, 13:17 +0100, Arno Schlipf @.***>, wrote:
Sounds good! Do you want to create a PR? Otherwise I could look into it later this week — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
This is doable with Vite and this plugin as-is, I believe. You can just set the build.assetsDir
to an empty string, like this:
// vite.config.js
export default {
build: {
// The outDir is where Vite will write build outputs, including assets
// and the `manifest.json` (Vite 3-4) or `.vite/manifest.json` (Vite 5).
outDir: 'public/assets',
// Optionally: clean out the outDir before writing new files
// emptyOutDir: true,
// Don't create an extra 'assets' directory in the outDir for generated JS/CSS/fonts/media
assetsDir: '',
},
};
You could also set build.outDir
to 'public'
and set build.assetsDir
to 'assets'
(or not set it, since that's the default value), and get the same result. The difference here is that with 'public'
as your build.outDir
you might end up with a few issues:
public/manifest.json
, but /manifest.json
is commonly used as a URL for Web app manifests.build.emptyOutDir
option, it clean delete all content in the public
directory, including other files that are not managed by Vite (like a public/index.php
maybe).So it's better to have build.outDir
point to a gitignored directory that is managed only by Vite and not used by other tools. And if you want Vite assets URLs to end up looking like /assets/something-{hash}.js
and not /dist/assets/something-{hash}.js
, then the config I've shown above is the way to go.
Thank you @fvsch for the information! Since I didn't receive a PR and you provided a good solution I will close this issue :)
I want to have my dist files right in public/assets (and not public/dist/assets). My src files are in "src/assets". For having this to work I need to specify my arnoson.kirby-vite.outDir to '.'
Maybe I suggest to change assetProd function in
kirby-vite/lib/Vite.php:97
by this :What do you think ?