Discovered a solution that actually works here
import { defineConfig } from 'vite'
import path from 'path'
import { readdirSync } from 'fs'
const absolutePathAliases: { [key: string]: string } = {};
// Root resources folder
const srcPath = path.resolve('./resources/');
// Adjust the regex here to include .vue, .js, .jsx, etc.. files from the resources/ folder
const srcRootContent = readdirSync(srcPath, { withFileTypes: true }).map((dirent) => dirent.name.replace(/(\.ts){1}(x?)/, ''));
srcRootContent.forEach((directory) => {
absolutePathAliases[directory] = path.join(srcPath, directory);
});
export default defineConfig({
root: 'resources',
resolve: {
alias: {
...absolutePathAliases
}
},
build: {
rollupOptions: {
input: '/main.ts'
}
}
});
Unsure if there's a more efficient or straightforward method available. It seems like something akin to baseUrl in a typescript configuration should suffice, but haven't come across an equivalent.