Skip to content

Commit

Permalink
feat(packaging): support tree shaking (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdehaven authored Jun 5, 2024
1 parent 298736c commit c9533d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Kong Icon Library",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/kong-icons.umd.js",
"main": "./dist/kong-icons.cjs",
"module": "./dist/kong-icons.es.js",
"files": [
"dist"
Expand All @@ -14,7 +14,7 @@
"exports": {
".": {
"import": "./dist/kong-icons.es.js",
"require": "./dist/kong-icons.umd.js",
"require": "./dist/kong-icons.cjs",
"types": "./dist/types/index.d.ts"
},
"./package.json": "./package.json",
Expand Down
12 changes: 11 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ export default defineConfig({
: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'KongIcons',
fileName: (format) => `kong-icons.${format}.js`,
fileName: (format) => {
if (format === 'cjs') {
return 'kong-icons.cjs'
} else {
return `kong-icons.${format}.js`
}
},
formats: ['es', 'cjs'],
},
emptyOutDir: true,
minify: true,
Expand All @@ -57,6 +64,9 @@ export default defineConfig({
vue: 'Vue',
},
exports: 'named',
preserveModules: true,
preserveModulesRoot: 'src',
inlineDynamicImports: false,
},
plugins: [
// visualizer must remain last in the list of plugins
Expand Down

0 comments on commit c9533d9

Please sign in to comment.