forked from opentiny/tiny-engine
fix(controller-environment): preserve import.meta.env variable when build controller lib (#380)
This commit is contained in:
parent
68838ed5f9
commit
0e6d30183a
|
@ -15,7 +15,7 @@
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist/index.js",
|
".": "./dist/index.js",
|
||||||
"./js/": "./js/",
|
"./js/": "./dist/js/",
|
||||||
"./utils": "./dist/utils.js",
|
"./utils": "./dist/utils.js",
|
||||||
"./adapter": "./dist/adapter.js"
|
"./adapter": "./dist/adapter.js"
|
||||||
},
|
},
|
||||||
|
@ -36,8 +36,8 @@
|
||||||
"@babel/traverse": "7.18.13",
|
"@babel/traverse": "7.18.13",
|
||||||
"@opentiny/tiny-engine-builtin-component": "workspace:*",
|
"@opentiny/tiny-engine-builtin-component": "workspace:*",
|
||||||
"@opentiny/tiny-engine-http": "workspace:*",
|
"@opentiny/tiny-engine-http": "workspace:*",
|
||||||
"@opentiny/tiny-engine-utils": "workspace:*",
|
|
||||||
"@opentiny/tiny-engine-i18n-host": "workspace:*",
|
"@opentiny/tiny-engine-i18n-host": "workspace:*",
|
||||||
|
"@opentiny/tiny-engine-utils": "workspace:*",
|
||||||
"@opentiny/vue": "~3.10.0",
|
"@opentiny/vue": "~3.10.0",
|
||||||
"@opentiny/vue-locale": "~3.10.0",
|
"@opentiny/vue-locale": "~3.10.0",
|
||||||
"@opentiny/vue-renderless": "~3.10.0",
|
"@opentiny/vue-renderless": "~3.10.0",
|
||||||
|
@ -48,6 +48,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.2.3",
|
"@vitejs/plugin-vue": "^4.2.3",
|
||||||
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
||||||
|
"glob": "^10.3.4",
|
||||||
"vite": "^4.3.7"
|
"vite": "^4.3.7"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
|
@ -14,6 +14,12 @@ import { defineConfig } from 'vite'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
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/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
@ -21,7 +27,8 @@ export default defineConfig({
|
||||||
publicDir: false,
|
publicDir: false,
|
||||||
resolve: {},
|
resolve: {},
|
||||||
define: {
|
define: {
|
||||||
'process.env': {}
|
'process.env': {},
|
||||||
|
'import.meta': 'import.meta'
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
cssCodeSplit: false,
|
cssCodeSplit: false,
|
||||||
|
@ -29,14 +36,15 @@ export default defineConfig({
|
||||||
entry: {
|
entry: {
|
||||||
index: path.resolve(__dirname, './src/index.js'),
|
index: path.resolve(__dirname, './src/index.js'),
|
||||||
adapter: path.resolve(__dirname, './adapter.js'),
|
adapter: path.resolve(__dirname, './adapter.js'),
|
||||||
utils: path.resolve(__dirname, './utils.js')
|
utils: path.resolve(__dirname, './utils.js'),
|
||||||
|
...Object.fromEntries(jsEntries)
|
||||||
},
|
},
|
||||||
name: 'controller',
|
name: 'controller',
|
||||||
fileName: (formats, entryName) => `${entryName}.js`,
|
fileName: (formats, entryName) => `${entryName}.js`,
|
||||||
formats: ['es']
|
formats: ['es']
|
||||||
},
|
},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: ['vue', /@opentiny\/tiny-engine.*/, /@opentiny\/vue.*/, /^prettier.*/]
|
external: ['vue', 'vue-i18n', /@opentiny\/tiny-engine.*/, /@opentiny\/vue.*/, /^prettier.*/, /^@babel.*/]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue