add support for extension vite plugin loading, add vue setup hook for extensions

This commit is contained in:
Gregor Vostrak
2024-04-23 22:37:30 +02:00
parent 2f0ad0eb44
commit a3196c4964
5 changed files with 70 additions and 40 deletions

View File

@@ -2,33 +2,49 @@ import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import checker from 'vite-plugin-checker';
import {
collectModuleAssetsPaths,
collectModulePlugins,
} from './vite-module-loader.js';
export default defineConfig({
plugins: [
laravel({
input: 'resources/js/app.ts',
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
checker({
// e.g. use TypeScript check
typescript: true,
vueTsc: true,
lintCommand: 'eslint "./**/*.{ts,vue}"',
}),
],
server: {
host: true,
hmr: {
host: process.env.VITE_HOST_NAME,
clientPort: 80,
async function getConfig() {
const paths = ['resources/js/app.ts'];
const modulePaths = await collectModuleAssetsPaths('extensions');
const additionalPlugins = await collectModulePlugins('extensions');
return defineConfig({
build: {
sourcemap: true, // Source map generation must be turned on
},
},
});
plugins: [
laravel({
input: [...paths, ...modulePaths],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
checker({
// e.g. use TypeScript check
typescript: true,
vueTsc: true,
lintCommand: 'eslint "./**/*.{ts,vue}"',
}),
...additionalPlugins,
],
server: {
host: true,
hmr: {
host: process.env.VITE_HOST_NAME,
clientPort: 80,
},
},
});
}
export default getConfig();