diff --git a/packages/controller/package.json b/packages/controller/package.json index 45d03de..b247c6f 100644 --- a/packages/controller/package.json +++ b/packages/controller/package.json @@ -15,7 +15,7 @@ ], "exports": { ".": "./dist/index.js", - "./js/": "./js/", + "./js/": "./dist/js/", "./utils": "./dist/utils.js", "./adapter": "./dist/adapter.js" }, @@ -36,8 +36,8 @@ "@babel/traverse": "7.18.13", "@opentiny/tiny-engine-builtin-component": "workspace:*", "@opentiny/tiny-engine-http": "workspace:*", - "@opentiny/tiny-engine-utils": "workspace:*", "@opentiny/tiny-engine-i18n-host": "workspace:*", + "@opentiny/tiny-engine-utils": "workspace:*", "@opentiny/vue": "~3.10.0", "@opentiny/vue-locale": "~3.10.0", "@opentiny/vue-renderless": "~3.10.0", @@ -48,6 +48,7 @@ "devDependencies": { "@vitejs/plugin-vue": "^4.2.3", "@vitejs/plugin-vue-jsx": "^3.1.0", + "glob": "^10.3.4", "vite": "^4.3.7" }, "peerDependencies": { diff --git a/packages/controller/vite.config.js b/packages/controller/vite.config.js index bd77aef..5602cfc 100644 --- a/packages/controller/vite.config.js +++ b/packages/controller/vite.config.js @@ -14,6 +14,12 @@ import { defineConfig } from 'vite' import path from 'path' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { glob } from 'glob' +import { fileURLToPath } from 'node:url' + +const jsEntries = glob.sync('./js/**.js').map((file) => { + return [file.slice(0, file.length - path.extname(file).length), fileURLToPath(new URL(file, import.meta.url))] +}) // https://vitejs.dev/config/ export default defineConfig({ @@ -21,7 +27,8 @@ export default defineConfig({ publicDir: false, resolve: {}, define: { - 'process.env': {} + 'process.env': {}, + 'import.meta': 'import.meta' }, build: { cssCodeSplit: false, @@ -29,14 +36,15 @@ export default defineConfig({ entry: { index: path.resolve(__dirname, './src/index.js'), adapter: path.resolve(__dirname, './adapter.js'), - utils: path.resolve(__dirname, './utils.js') + utils: path.resolve(__dirname, './utils.js'), + ...Object.fromEntries(jsEntries) }, name: 'controller', fileName: (formats, entryName) => `${entryName}.js`, formats: ['es'] }, rollupOptions: { - external: ['vue', /@opentiny\/tiny-engine.*/, /@opentiny\/vue.*/, /^prettier.*/] + external: ['vue', 'vue-i18n', /@opentiny\/tiny-engine.*/, /@opentiny\/vue.*/, /^prettier.*/, /^@babel.*/] } } })