增加任务
This commit is contained in:
@@ -1,51 +1,63 @@
|
||||
import {defineConfig} from 'vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
import federation from '@originjs/vite-plugin-federation';
|
||||
import {fileURLToPath, URL} from "node:url";
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
import { nacosServiceManage } from "nacos-federation";
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
port: 1301,
|
||||
host: '0.0.0.0',
|
||||
strictPort: true,
|
||||
},
|
||||
plugins: [
|
||||
federation({
|
||||
name: 'product',
|
||||
remotes: {
|
||||
shared: 'http://localhost:1333/assets/remoteEntry.js'
|
||||
},
|
||||
exposes: { // 暴露给主应用的资源(按功能分组)
|
||||
'./ProductDomain': './src/domains/product/index.ts', // 领域层(实体、服务、接口等)
|
||||
'./ProductRouter': './src/features/product/router/index.ts' // 商品路由
|
||||
},
|
||||
shared: {
|
||||
vue: {import: false, generate: false, requiredVersion: '^3.5.18'},
|
||||
'vue-router': {import: false, generate: false, requiredVersion: '^4.0.6'},
|
||||
pinia: {import: false, generate: false, requiredVersion: '^3.0.3'},
|
||||
}
|
||||
}),
|
||||
vue(),
|
||||
vueJsx(),
|
||||
vueDevTools()
|
||||
],
|
||||
build: {
|
||||
target: 'esnext',
|
||||
cssCodeSplit: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
minifyInternalExports: false
|
||||
}
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src/', import.meta.url)),
|
||||
'@shared': fileURLToPath(new URL('./src/shared/', import.meta.url)),
|
||||
'@features': fileURLToPath(new URL('./src/features/', import.meta.url)),
|
||||
'@domains': fileURLToPath(new URL('./src/domains/', import.meta.url))
|
||||
|
||||
export default defineConfig(async () => {
|
||||
const client = new nacosServiceManage({
|
||||
serverList: '192.168.31.100:8848',
|
||||
serviceName: 'app-product',
|
||||
port: 1301
|
||||
})
|
||||
const sharedUrl = await client.find("app-shared")
|
||||
|
||||
return {
|
||||
server: {
|
||||
port: 1301,
|
||||
host: '0.0.0.0',
|
||||
strictPort: true,
|
||||
cors: true
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
federation({
|
||||
name: 'product',
|
||||
remotes: {
|
||||
shared: `${ sharedUrl }/assets/remoteEntry.js`
|
||||
},
|
||||
exposes: { // 暴露给主应用的资源(按功能分组)
|
||||
'./ProductDomain': './src/domains/product/index.ts', // 领域层(实体、服务、接口等)
|
||||
'./ProductRouter': './src/features/product/router/index.ts' // 商品路由
|
||||
},
|
||||
shared: {
|
||||
vue: { import: false, generate: false, requiredVersion: '^3.5.18' },
|
||||
'vue-router': { import: false, generate: false, requiredVersion: '^4.0.6' },
|
||||
pinia: { import: false, generate: false, requiredVersion: '^3.0.3' },
|
||||
}
|
||||
}),
|
||||
vue(),
|
||||
vueJsx(),
|
||||
vueDevTools()
|
||||
],
|
||||
build: {
|
||||
target: 'esnext',
|
||||
cssCodeSplit: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
minifyInternalExports: false
|
||||
}
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src/', import.meta.url)),
|
||||
'@shared': fileURLToPath(new URL('./src/shared/', import.meta.url)),
|
||||
'@features': fileURLToPath(new URL('./src/features/', import.meta.url)),
|
||||
'@domains': fileURLToPath(new URL('./src/domains/', import.meta.url))
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user