-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: build system * refactor: remove preloading optimization for dependencies in Vite config
- Loading branch information
1 parent
59cba4f
commit 531f4b8
Showing
5 changed files
with
92 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,65 @@ | ||
import process from 'node:process' | ||
// import { externalizeDeps } from 'vite-plugin-externalize-deps' | ||
|
||
import { execSync } from 'node:child_process' | ||
import { resolve } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import vue from '@vitejs/plugin-vue' | ||
import vueJsx from '@vitejs/plugin-vue-jsx' | ||
import { globbySync } from 'globby' | ||
import { defineConfig } from 'vite' | ||
import dts from 'vite-plugin-dts' | ||
import pkg from './package.json' | ||
|
||
const projectRootDir = resolve(__dirname) | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
define: { | ||
__DEV__: process.env.NODE_ENV !== 'production', | ||
}, | ||
plugins: [ | ||
// externalizeDeps(), | ||
vue(), | ||
vue({ | ||
template: { | ||
compilerOptions: { | ||
hoistStatic: true, | ||
cacheHandlers: true, | ||
}, | ||
}, | ||
}), | ||
vueJsx(), | ||
dts({ | ||
outDir: 'dist', | ||
exclude: ['src/**/__tests__/*', 'src/**/stories/*'], | ||
compilerOptions: { | ||
composite: false, | ||
declaration: true, | ||
declarationMap: true, | ||
}, | ||
tsconfigPath: 'tsconfig.build.json', | ||
afterBuild: async () => { | ||
console.log('dts afterBuild') | ||
// pnpm build:plugins | ||
execSync('pnpm build:plugins', { stdio: 'inherit', cwd: resolve(__dirname, '../plugins') }) | ||
execSync('pnpm generate:plugins', { stdio: 'inherit', cwd: resolve(__dirname, '../plugins') }) | ||
execSync('pnpm lint:fix', { stdio: 'inherit', cwd: resolve(__dirname, '../..') }) | ||
}, | ||
exclude: ['src/test/**', 'src/**/stories/**', 'src/**/*.stories.vue'], | ||
rollupTypes: true, | ||
}), | ||
], | ||
resolve: { | ||
alias: { | ||
'@': resolve(projectRootDir, 'src'), | ||
}, | ||
dedupe: ['vue', '@vue/runtime-core'], | ||
}, | ||
build: { | ||
copyPublicDir: false, | ||
minify: false, | ||
target: 'esnext', | ||
sourcemap: true, | ||
lib: { | ||
name: 'oku-ui-primitives', | ||
formats: ['es'], | ||
entry: [ | ||
...globbySync('src/**/*.ts', { ignore: [ | ||
'**/__tests__/**', | ||
'**/stories/**', | ||
'**/*.stories.ts', | ||
] }), | ||
'src/index.ts', | ||
], | ||
fileName: (_, name) => `${name}.mjs`, | ||
entry: { | ||
index: resolve(__dirname, 'src/index.ts'), | ||
}, | ||
}, | ||
target: 'esnext', | ||
rollupOptions: { | ||
output: { | ||
esModule: true, | ||
preserveModules: true, | ||
preserveModulesRoot: 'src', | ||
entryFileNames: '[name].mjs', | ||
}, | ||
external: [ | ||
'vue', | ||
'@vue/shared', | ||
'@floating-ui/dom', | ||
'@floating-ui/utils', | ||
'@floating-ui/vue', | ||
'aria-hidden', | ||
...Object.keys(pkg.dependencies ?? {}), | ||
...Object.keys(pkg.peerDependencies ?? {}), | ||
], | ||
output: { | ||
manualChunks: (id) => { | ||
// Daha basit chunk stratejisi | ||
const chunks = id.match(/[/\\]src[/\\](.*?)[/\\]/) | ||
return chunks ? chunks[1] : null | ||
}, | ||
exports: 'named', | ||
chunkFileNames: '[name].mjs', | ||
assetFileNames: 'index.css', | ||
hoistTransitiveImports: false, | ||
minifyInternalExports: true, | ||
}, | ||
}, | ||
|
||
}, | ||
resolve: { | ||
alias: { | ||
'@oku-ui': fileURLToPath(new URL('./src', import.meta.url)), | ||
}, | ||
}, | ||
// resolve: { | ||
// alias: { | ||
// '~': fileURLToPath(new URL('./src', import.meta.url)), | ||
// }, | ||
// }, | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.