Skip to content

Commit

Permalink
add config/vite export and defineConfig helper
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jul 18, 2024
1 parent 4f439f2 commit d95687a
Show file tree
Hide file tree
Showing 10 changed files with 927 additions and 1,544 deletions.
2 changes: 0 additions & 2 deletions config.d.ts

This file was deleted.

Empty file added config/nuxt.d.ts
Empty file.
Empty file added config/nuxt.js
Empty file.
8 changes: 8 additions & 0 deletions config/vite.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare const baseConfig: import('vite').UserConfig

declare function defineConfig(config?: import('vite').UserConfig): import('vite').UserConfig
declare function defineConfig(config?: Promise<import('vite').UserConfig>): Promise<import('vite').UserConfig>
declare function defineConfig(config?: import('vite').UserConfigFnObject): import('vite').UserConfigFnObject
declare function defineConfig(config?: import('vite').UserConfigExport): import('vite').UserConfigExport

export { baseConfig, defineConfig }
18 changes: 14 additions & 4 deletions config.js → config/vite.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

import Icons from 'unplugin-icons/vite'
import { defineConfig } from 'vite'
import { mergeConfig } from 'vite'
import { compileTemplate } from 'vue/compiler-sfc'

const randIdFn = 'const __randId = () => Math.random().toString(36).substr(2, 10);'
Expand Down Expand Up @@ -69,11 +69,13 @@ function compiler(svg, collection, icon) {
return code
}

export default defineConfig({
/** @type {import('vite').UserConfig} */
export const baseConfig = {
// TODO:: remove custom compiler when unplugin-icons is updated
plugins: [Icons({ scale: 1, compiler: { compiler } })],

resolve: {
alias: { 'sefirot/': new URL('./lib/', import.meta.url).pathname },
alias: { 'sefirot/': new URL('../lib/', import.meta.url).pathname },

dedupe: [
'@sentry/browser',
Expand Down Expand Up @@ -111,4 +113,12 @@ export default defineConfig({
'markdown-it'
]
}
})
}

/**
* @param {import('vite').UserConfigExport} config
*/
export function defineConfig(config = {}) {
return async (/** @type {import("vite").ConfigEnv} */ configEnv) =>
mergeConfig(baseConfig, await (typeof config === 'function' ? config(configEnv) : config))
}
2 changes: 1 addition & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig, type DefaultTheme } from 'vitepress'
import baseConfig from '../../config'
import { baseConfig } from '../../config/vite'

function getStoryHost(): string {
if (process.env.CONTEXT !== 'production' && process.env.DEPLOY_PRIME_URL) {
Expand Down
2 changes: 1 addition & 1 deletion histoire.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HstVue } from '@histoire/plugin-vue'
import { defaultColors, defineConfig } from 'histoire'
import baseConfig from './config'
import { baseConfig } from './config/vite'

function getDocsHost(): string {
if (process.env.CONTEXT !== 'production' && process.env.DEPLOY_PRIME_URL) {
Expand Down
39 changes: 19 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@globalbrain/sefirot",
"type": "module",
"version": "3.49.0",
"packageManager": "pnpm@9.4.0",
"packageManager": "pnpm@9.5.0",
"description": "Vue Components for Global Brain Design System.",
"author": "Kia Ishii <[email protected]>",
"license": "MIT",
Expand All @@ -20,8 +20,7 @@
],
"files": [
"lib",
"config.js",
"config.d.ts"
"config"
],
"scripts": {
"docs": "pnpm docs:dev",
Expand All @@ -48,7 +47,7 @@
"@types/body-scroll-lock": "^3.1.2",
"@types/lodash-es": "^4.17.12",
"@types/markdown-it": "^14.1.1",
"@vue/reactivity": "^3.4.30",
"@vue/reactivity": "^3.4.32",
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
"@vueuse/core": "^10.11.0",
Expand All @@ -59,23 +58,23 @@
"markdown-it": "^14.1.0",
"normalize.css": "^8.0.1",
"pinia": "^2.1.7",
"postcss": "^8.4.38",
"postcss": "^8.4.39",
"postcss-nested": "^6.0.1",
"unplugin-icons": "^0.19.0",
"v-calendar": "^3.1.2",
"vue": "^3.4.30",
"vue": "^3.4.32",
"vue-router": "^4.4.0"
},
"dependencies": {
"@sentry/browser": "^8.13.0",
"@sentry/browser": "^8.18.0",
"@tanstack/vue-virtual": "3.0.0-beta.62",
"@tinyhttp/content-disposition": "^2.2.1",
"@tinyhttp/cookie": "^2.1.1",
"@types/file-saver": "^2.0.7",
"@types/qs": "^6.9.15",
"file-saver": "^2.0.5",
"ofetch": "^1.3.4",
"qs": "^6.12.1"
"qs": "^6.12.3"
},
"devDependencies": {
"@globalbrain/eslint-config": "^1.6.0",
Expand All @@ -86,10 +85,10 @@
"@types/body-scroll-lock": "^3.1.2",
"@types/lodash-es": "^4.17.12",
"@types/markdown-it": "^14.1.1",
"@types/node": "^20.14.9",
"@types/node": "^20.14.11",
"@vitejs/plugin-vue": "^5.0.5",
"@vitest/coverage-v8": "^1.6.0",
"@vue/reactivity": "^3.4.30",
"@vitest/coverage-v8": "^2.0.3",
"@vue/reactivity": "^3.4.32",
"@vue/test-utils": "^2.4.6",
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
Expand All @@ -104,18 +103,18 @@
"markdown-it": "^14.1.0",
"normalize.css": "^8.0.1",
"pinia": "^2.1.7",
"postcss": "^8.4.38",
"postcss": "^8.4.39",
"postcss-nested": "^6.0.1",
"punycode": "^2.3.1",
"release-it": "^17.4.0",
"typescript": "~5.5.2",
"unplugin-icons": "^0.19.0",
"release-it": "^17.6.0",
"typescript": "~5.5.3",
"unplugin-icons": "npm:@globalbrain/unplugin-icons@^0.19.1",
"v-calendar": "^3.1.2",
"vite": "^5.3.2",
"vitepress": "^1.2.3",
"vitest": "^1.6.0",
"vue": "^3.4.30",
"vite": "^5.3.4",
"vitepress": "^1.3.1",
"vitest": "^2.0.3",
"vue": "^3.4.32",
"vue-router": "^4.4.0",
"vue-tsc": "^2.0.22"
"vue-tsc": "^2.0.26"
}
}
Loading

0 comments on commit d95687a

Please sign in to comment.