47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import { defineConfig, loadEnv } from 'vite';
|
|
import laravel from 'laravel-vite-plugin';
|
|
import vue from "@vitejs/plugin-vue";
|
|
import path from "path";
|
|
import tsconfig from "./tsconfig.json";
|
|
|
|
// https://github.com/vitejs/vite/issues/6828#issuecomment-1059770150
|
|
const tsconfigPathAliases = Object.fromEntries(
|
|
Object.entries(tsconfig.compilerOptions.paths).map(([key, values]) => {
|
|
let value = values[0];
|
|
if (key.endsWith("/*")) {
|
|
key = key.slice(0, -2);
|
|
value = value.slice(0, -2);
|
|
}
|
|
|
|
const nodeModulesPrefix = "node_modules/";
|
|
if (value.startsWith(nodeModulesPrefix)) {
|
|
value = value.replace(nodeModulesPrefix, "");
|
|
} else {
|
|
value = path.join(__dirname, value);
|
|
}
|
|
|
|
return [key, value];
|
|
})
|
|
);
|
|
|
|
export default defineConfig(({mode}) => {
|
|
process.env = {...process.env, ...loadEnv(mode, process.cwd())}
|
|
return {
|
|
plugins: [
|
|
vue(),
|
|
laravel({
|
|
input: [
|
|
'resources/css/app.css',
|
|
'resources/js/app.ts',
|
|
],
|
|
refresh: true,
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: tsconfigPathAliases,
|
|
},
|
|
build: {
|
|
sourcemap: true,
|
|
},
|
|
}
|
|
});
|