mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-14 04:15:40 +00:00
build: update config
This commit is contained in:
1 parent
04d15375b2
commit
6fb35fc7aa
6 files changed
+429
-8
No files matched your search
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Vite Configuration for Vendoring JavaScript Libraries
|
||||
*
|
||||
* This config is used by Hugo Blox maintainers to copy third-party
|
||||
* JavaScript libraries from node_modules into the Hugo module's assets.
|
||||
*
|
||||
* Usage: pnpm run vendor:libs
|
||||
*/
|
||||
|
||||
import { defineConfig } from 'vite';
|
||||
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
||||
import { resolve } from 'path';
|
||||
import del from 'rollup-plugin-delete';
|
||||
|
||||
const MODULE_DIR = 'modules/blox-tailwind';
|
||||
const OUTPUT_DIR = resolve(MODULE_DIR, 'assets/dist/lib');
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
emptyOutDir: true,
|
||||
outDir: OUTPUT_DIR,
|
||||
lib: {
|
||||
entry: resolve(MODULE_DIR, 'assets/js/vendor-libs.js'),
|
||||
formats: ['es'],
|
||||
fileName: 'vendor-libs'
|
||||
},
|
||||
rollupOptions: {
|
||||
// Don't bundle these libraries, just copy them
|
||||
external: ['mermaid', 'plotly.js', 'katex', 'markmap-autoloader'],
|
||||
}
|
||||
},
|
||||
|
||||
plugins: [
|
||||
// Copy vendor libraries to module assets
|
||||
viteStaticCopy({
|
||||
targets: [
|
||||
// Mermaid - Diagram rendering
|
||||
{
|
||||
src: 'node_modules/mermaid/dist/mermaid.min.js',
|
||||
dest: 'mermaid/'
|
||||
},
|
||||
|
||||
// Plotly - Interactive charts
|
||||
{
|
||||
src: 'node_modules/plotly.js/dist/plotly.min.js',
|
||||
dest: 'plotly/'
|
||||
},
|
||||
|
||||
// KaTeX - Math rendering
|
||||
{
|
||||
src: 'node_modules/katex/dist/katex.min.js',
|
||||
dest: 'katex/'
|
||||
},
|
||||
{
|
||||
src: 'node_modules/katex/dist/katex.min.css',
|
||||
dest: 'katex/'
|
||||
},
|
||||
{
|
||||
src: 'node_modules/katex/dist/contrib/auto-render.min.js',
|
||||
dest: 'katex/'
|
||||
},
|
||||
{
|
||||
src: 'node_modules/katex/dist/fonts/',
|
||||
dest: 'katex/'
|
||||
},
|
||||
|
||||
// Markmap - Mind map rendering
|
||||
{
|
||||
src: 'node_modules/markmap-autoloader/dist/index.js',
|
||||
dest: 'markmap/',
|
||||
rename: 'markmap-autoloader.min.js'
|
||||
}
|
||||
]
|
||||
}),
|
||||
|
||||
// Clean up any unwanted build artifacts
|
||||
del({
|
||||
targets: `${OUTPUT_DIR}/vendor-libs.js`, // Remove the dummy entry file
|
||||
hook: 'writeBundle'
|
||||
})
|
||||
]
|
||||
});
|
||||
Reference in new issue
Block a user