Skip to content

Commit

Permalink
feat: add unplugin-config plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Oct 13, 2023
1 parent 28ef9c8 commit 04db2fb
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"crypto-js": "^4.1.1",
"dayjs": "^1.11.10",
"destr": "^2.0.1",
"dotenv": "^16.3.1",
"iso-639-1": "^3.1.0",
"lodash-es": "^4.17.21",
"nprogress": "^0.2.0",
Expand Down Expand Up @@ -73,6 +74,7 @@
"unocss-preset-chinese": "^0.3.0",
"unocss-preset-ease": "^0.0.3",
"unplugin-auto-import": "^0.16.6",
"unplugin-config": "^0.1.3",
"unplugin-icons": "^0.17.0",
"unplugin-vue-components": "^0.25.2",
"vite": "^4.4.11",
Expand Down
52 changes: 51 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion types/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export {}

declare module 'vue' {
export interface GlobalComponents {
BVIcon: typeof import('./../src/components/Icon/BVIcon.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
UnoCSSIconButton: typeof import('./../src/components/Icon/UnoCSSIconButton.vue')['default']
Expand Down
22 changes: 22 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ import Icons from "unplugin-icons/vite";
import { FileSystemIconLoader } from "unplugin-icons/loaders";
import IconsResolver from "unplugin-icons/resolver";
import { VitePWA } from "vite-plugin-pwa";
import GenerateConfig from "unplugin-config/vite";

// vite.config.ts
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
import UnoCss from "unocss/vite";

// This constant defines the name of the configuration file that will be used in the production environment
const GLOB_CONFIG_FILE_NAME = "_app.config.js";

// This constant sets the output directory for the Vite package
const OUTPUT_DIR = "dist";

// This constant sets the name of the application
const APP_NAME = "boot-vant";

// https://vitejs.dev/config/
export default defineConfig({
server: {
Expand Down Expand Up @@ -113,6 +123,18 @@ export default defineConfig({
// https://github.com/unocss/unocss
// see unocss.config.ts for config
UnoCss(),

GenerateConfig({
appName: APP_NAME,
envVariables: {
prefix: "VITE_GLOB_",
},
configFile: {
generate: true,
fileName: GLOB_CONFIG_FILE_NAME,
outputDir: OUTPUT_DIR,
},
}),
],
resolve: {
alias: {
Expand Down

0 comments on commit 04db2fb

Please sign in to comment.