Update import/exports to be more tree-shake friendly
This commit is contained in:
@@ -6,9 +6,13 @@ import { resolve } from "node:path";
|
||||
import removeTestIdAttribute from "rollup-plugin-jsx-remove-attributes";
|
||||
import { defineConfig } from "vite";
|
||||
import dts from "vite-plugin-dts";
|
||||
import { viteStaticCopy } from "vite-plugin-static-copy";
|
||||
import { peerDependencies } from "./package.json";
|
||||
|
||||
|
||||
const modules = [ "button", "input", "loading", "message", "modal", "nav", "progress", "tab", "toaster" ];
|
||||
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -27,7 +31,15 @@ export default defineConfig({
|
||||
declarationMap: false
|
||||
}
|
||||
}),
|
||||
removeTestIdAttribute({ usage: "vite" })
|
||||
removeTestIdAttribute({ usage: "vite" }),
|
||||
viteStaticCopy({
|
||||
targets: [
|
||||
{
|
||||
src: resolve(__dirname, "lib/styles.css"),
|
||||
dest: ""
|
||||
}
|
||||
]
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
@@ -38,8 +50,11 @@ export default defineConfig({
|
||||
},
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, "lib/index.ts"),
|
||||
formats: [ "cjs", "es" ],
|
||||
entry: {
|
||||
index: resolve(__dirname, "lib/index.ts"),
|
||||
...Object.fromEntries(modules.map(mod => [mod, resolve(__dirname, `lib/component/${mod}/index.ts`)]))
|
||||
},
|
||||
formats: [ "es" ],
|
||||
name: "Mattrixwv Component Library"
|
||||
},
|
||||
rollupOptions: {
|
||||
@@ -54,7 +69,13 @@ export default defineConfig({
|
||||
react: "React",
|
||||
"react-dom": "ReactDOM"
|
||||
},
|
||||
manualChunks: undefined
|
||||
hoistTransitiveImports: false,
|
||||
manualChunks: undefined,
|
||||
entryFileNames: "[name].js",
|
||||
chunkFileNames: "_internal/[name]-[hash].js"
|
||||
},
|
||||
treeshake: {
|
||||
moduleSideEffects: false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user