fix(bundle): fix env variable can not be bundle (#16)

This commit is contained in:
chilingling 2023-10-07 11:49:45 +08:00 committed by GitHub
parent f3c03e5b6d
commit 790720985d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 12 deletions

View File

@ -11,10 +11,11 @@
"module": "dist/index.js", "module": "dist/index.js",
"exports": { "exports": {
".": "./dist/index.js", ".": "./dist/index.js",
"./js/*": "./dist/js/*.js" "./js/*": "./js/*.js"
}, },
"files": [ "files": [
"dist" "dist",
"js"
], ],
"dependencies": { "dependencies": {
"@babel/generator": "7.18.13", "@babel/generator": "7.18.13",
@ -40,7 +41,6 @@
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^4.2.3", "@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^1.3.10", "@vitejs/plugin-vue-jsx": "^1.3.10",
"glob": "^10.3.4",
"vite": "^4.3.7" "vite": "^4.3.7"
} }
} }

View File

@ -14,12 +14,6 @@ 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({
@ -33,8 +27,7 @@ export default defineConfig({
cssCodeSplit: false, cssCodeSplit: false,
lib: { lib: {
entry: { entry: {
index: path.resolve(__dirname, './index.js'), index: path.resolve(__dirname, './index.js')
...Object.fromEntries(jsEntries)
}, },
name: 'common', name: 'common',
fileName: (format, entryName) => `${entryName}.js`, fileName: (format, entryName) => `${entryName}.js`,

View File

@ -1,4 +1,4 @@
# alpha mode, used by the "build:alpha" script # alpha mode, used by the "build:alpha" script
NODE_ENV=production NODE_ENV=production
#VITE_ORIGIN= # VITE_ORIGIN=