refactor: module federation
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
13
src/main.ts
13
src/main.ts
@@ -1,7 +1,3 @@
|
|||||||
import { useNodesStore } from '@/stores/nodesStore'
|
|
||||||
import { useProvidersStore } from '@/stores/providersStore'
|
|
||||||
import { useServicesStore } from '@/stores/servicesStore'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File Manager Module Boot Script
|
* File Manager Module Boot Script
|
||||||
*
|
*
|
||||||
@@ -13,5 +9,10 @@ console.log('[FileManager] Booting File Manager module...')
|
|||||||
|
|
||||||
console.log('[FileManager] File Manager module booted successfully')
|
console.log('[FileManager] File Manager module booted successfully')
|
||||||
|
|
||||||
// Export stores for external use if needed
|
// CSS will be injected by build process
|
||||||
export { useNodesStore, useProvidersStore, useServicesStore }
|
//export const css = ['__CSS_FILENAME_PLACEHOLDER__']
|
||||||
|
|
||||||
|
// Export services, stores and models for external use
|
||||||
|
export * from '@/services'
|
||||||
|
export * from '@/stores'
|
||||||
|
export * from '@/models'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Central service for making API calls to the file manager backend
|
* Central service for making API calls to the file manager backend
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createFetchWrapper } from '@KTXC/utils/helpers/fetch-wrapper-core';
|
import { createFetchWrapper } from '@KTXC';
|
||||||
|
|
||||||
const fetchWrapper = createFetchWrapper();
|
const fetchWrapper = createFetchWrapper();
|
||||||
|
|
||||||
|
|||||||
3
src/stores/index.ts
Normal file
3
src/stores/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export { useProvidersStore } from './providersStore';
|
||||||
|
export { useServicesStore } from './servicesStore';
|
||||||
|
export { useNodesStore, ROOT_ID } from './nodesStore';
|
||||||
@@ -1,16 +1,38 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
{
|
||||||
|
name: 'inject-css-filename',
|
||||||
|
enforce: 'post',
|
||||||
|
generateBundle(_options, bundle) {
|
||||||
|
const cssFile = Object.keys(bundle).find(name => name.endsWith('.css'))
|
||||||
|
if (!cssFile) return
|
||||||
|
|
||||||
|
for (const fileName of Object.keys(bundle)) {
|
||||||
|
const chunk = bundle[fileName]
|
||||||
|
if (chunk.type === 'chunk' && chunk.code.includes('__CSS_FILENAME_PLACEHOLDER__')) {
|
||||||
|
chunk.code = chunk.code.replace(/__CSS_FILENAME_PLACEHOLDER__/g, `static/${cssFile}`)
|
||||||
|
console.log(`Injected CSS filename "static/${cssFile}" into ${fileName}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': path.resolve(__dirname, './src'),
|
'@': path.resolve(__dirname, './src'),
|
||||||
'@KTXC': path.resolve(__dirname, '../../core/src')
|
'@KTXC': path.resolve(__dirname, '../../core/src'),
|
||||||
|
'@FilesManager': path.resolve(__dirname, './src')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: 'static',
|
outDir: 'static',
|
||||||
|
emptyOutDir: true,
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
lib: {
|
lib: {
|
||||||
entry: path.resolve(__dirname, 'src/main.ts'),
|
entry: path.resolve(__dirname, 'src/main.ts'),
|
||||||
@@ -19,12 +41,23 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: [
|
external: [
|
||||||
'pinia',
|
|
||||||
'vue',
|
'vue',
|
||||||
'vue-router',
|
'vue-router',
|
||||||
// Externalize shared utilities from core to avoid duplication
|
'pinia',
|
||||||
/^@KTXC\/utils\//,
|
'@KTXC',
|
||||||
],
|
],
|
||||||
|
output: {
|
||||||
|
paths: (id) => {
|
||||||
|
if (id === '@KTXC') return '/js/ktxc.mjs'
|
||||||
|
return id
|
||||||
|
},
|
||||||
|
assetFileNames: (assetInfo) => {
|
||||||
|
if (assetInfo.name?.endsWith('.css')) {
|
||||||
|
return 'file_manager-[hash].css'
|
||||||
|
}
|
||||||
|
return '[name]-[hash][extname]'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user