Merge pull request 'refactor: module federation' (#4) from refactor/module-federation into main
Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
14
src/main.ts
14
src/main.ts
@@ -1,8 +1,3 @@
|
||||
import { useCollectionsStore } from '@/stores/collectionsStore'
|
||||
import { useEntitiesStore } from '@/stores/entitiesStore'
|
||||
import { useProvidersStore } from '@/stores/providersStore'
|
||||
import { useServicesStore } from '@/stores/servicesStore'
|
||||
|
||||
/**
|
||||
* Chrono Manager Module Boot Script
|
||||
*
|
||||
@@ -14,5 +9,10 @@ console.log('[Chrono Manager] Booting Chrono Manager module...')
|
||||
|
||||
console.log('[Chrono Manager] Chrono Manager module booted successfully')
|
||||
|
||||
// Export store for external use if needed
|
||||
export { useCollectionsStore, useEntitiesStore, useProvidersStore, useServicesStore }
|
||||
// CSS will be injected by build process
|
||||
//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 @@
|
||||
* Provides a centralized way to make API calls with envelope wrapping/unwrapping
|
||||
*/
|
||||
|
||||
import { createFetchWrapper } from '@KTXC/utils/helpers/fetch-wrapper-core';
|
||||
import { createFetchWrapper } from '@KTXC';
|
||||
import type { ApiRequest, ApiResponse } from '../types/common';
|
||||
|
||||
const fetchWrapper = createFetchWrapper();
|
||||
|
||||
@@ -1,16 +1,38 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'path'
|
||||
|
||||
// https://vite.dev/config/
|
||||
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: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
'@KTXC': path.resolve(__dirname, '../../core/src')
|
||||
'@KTXC': path.resolve(__dirname, '../../core/src'),
|
||||
'@ChronoManager': path.resolve(__dirname, './src')
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: 'static',
|
||||
emptyOutDir: true,
|
||||
sourcemap: true,
|
||||
lib: {
|
||||
entry: path.resolve(__dirname, 'src/main.ts'),
|
||||
@@ -19,12 +41,23 @@ export default defineConfig({
|
||||
},
|
||||
rollupOptions: {
|
||||
external: [
|
||||
'pinia',
|
||||
'vue',
|
||||
'vue-router',
|
||||
// Externalize shared utilities from core to avoid duplication
|
||||
/^@KTXC\/utils\//,
|
||||
'pinia',
|
||||
'@KTXC',
|
||||
],
|
||||
output: {
|
||||
paths: (id) => {
|
||||
if (id === '@KTXC') return '/js/ktxc.mjs'
|
||||
return id
|
||||
},
|
||||
assetFileNames: (assetInfo) => {
|
||||
if (assetInfo.name?.endsWith('.css')) {
|
||||
return 'chrono_manager-[hash].css'
|
||||
}
|
||||
return '[name]-[hash][extname]'
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user