In order to keep the structure that I want in resources folder, I have done like this:
In the views -> admin -> app.blade.php
:
{{ Vite::useBuildDirectory('admin')->withEntryPoints(['resources/admin/sass/app.scss', 'resources/admin/js/app.js']) }}
In the resources -> admin folder, I let it only the js + sass folders (the app itself) and in the root project I have added those two configs:
vite.admin.config.js
vite.store.config.js
vite.admin.config.js
import {defineConfig} from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
laravel({
buildDirectory: 'admin',
input: ['resources/admin/sass/app.scss', 'resources/admin/js/app.js'],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
'@': '/resources/admin/js',
}
},
server: {
host: '0.0.0.0',
hmr: {
clientPort: 5173,
host: 'localhost',
},
fs: {
cachedChecks: false
}
}
});
and in the package.json:
...
"scripts": {
"dev.store": "vite --config vite.store.config.js",
"build.store": "vite build --config vite.store.config.js",
"dev.admin": "vite --config vite.admin.config.js",
"build.admin": "vite build --config vite.admin.config.js"
},
...
and is working, the dev server and the build :)