Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
docs(build): link package.json and output
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdvl committed Oct 25, 2022
1 parent 25b84b2 commit 9679bb7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import react from '@vitejs/plugin-react';
import visualizer from 'rollup-plugin-visualizer';
import pkg from './package.json';

/** Get build directory from package.json */
const outDir = pkg.module.split("/")[0];

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Expand All @@ -11,13 +14,15 @@ export default defineConfig({
}),
],
build: {
outDir: "build",
outDir,
lib: {
entry: "./src/App.tsx",
formats: ["cjs","es"],
fileName: (format) => {
// Ensure the file names matches the package.json’s ones
const path = format === "es" ? pkg.module : pkg.main
return path.split("/").slice(-1)[0];
// Strip out the build directory from the filename
return path.replace(`${outDir}/`, "");
},
},
rollupOptions:
Expand Down

0 comments on commit 9679bb7

Please sign in to comment.