Created
November 29, 2022 18:15
-
-
Save h-sigma/9f456df768db17d9747103443d501d4f to your computer and use it in GitHub Desktop.
Component Library setup
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
//partial | |
"files": [ | |
"src", | |
"dist" | |
], | |
"types": "./dist/types/index.d.ts", | |
"module": "./dist/mega-components-lib.es.js", | |
"exports": { | |
".": { | |
"import": "./dist/mega-components-lib.es.js" | |
}, | |
"./dist/style.css": "./dist/style.css", | |
"./dist/style.scss" : "./src/assets/sass/style.scss" | |
} |
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
Show hidden characters
{ | |
"extends": "@vue/tsconfig/tsconfig.json", | |
"compilerOptions": { | |
"target": "esnext", | |
"useDefineForClassFields": true, | |
"module": "esnext", | |
"moduleResolution": "node", | |
"strict": true, | |
"jsx": "preserve", | |
"sourceMap": true, | |
"resolveJsonModule": true, | |
"esModuleInterop": true, | |
"lib": ["esnext", "dom"], | |
"declaration": true, | |
"emitDeclarationOnly": true, | |
"declarationDir": "./dist/types", | |
"isolatedModules": true, | |
"skipLibCheck": true, | |
"types": ["vite/client"], | |
}, | |
"include": ["./src/**/*.ts", "./src/**/*.d.ts", "./src/**/*.tsx", "./src/**/*.vue", "./src/index.ts", "demo/**/*"], | |
"references": [{ "path": "./tsconfig.node.json" }] | |
} |
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
import vue from '@vitejs/plugin-vue'; | |
// eslint-disable-next-line @typescript-eslint/no-var-requires | |
const path = require('path'); | |
import { defineConfig } from 'vite'; | |
import dts from 'vite-plugin-dts'; | |
import tsconfigPaths from 'vite-tsconfig-paths'; | |
module.exports = defineConfig(() => ({ | |
plugins: [ | |
vue(), | |
dts({ | |
outputDir: 'dist/types', | |
exclude: ['demo', 'docs'] | |
}), | |
tsconfigPaths(), | |
], // to process SFC | |
build: { | |
lib: { | |
entry: path.resolve(__dirname, 'src/index.ts'), | |
name: 'mega-components-lib', | |
formats: ['es'], // adding 'umd' requires globals set to every external module | |
fileName: format => `mega-components-lib.${format}.js`, //uncomment when bundling | |
}, | |
rollupOptions: { | |
// external modules won't be bundled into your library | |
external: ['vue'], // not every external has a global | |
output: { | |
// disable warning on src/index.ts using both default and named export | |
exports: 'named', | |
// Provide global variables to use in the UMD build | |
// for externalized deps (not useful if 'umd' is not in lib.formats) | |
globals: { | |
vue: 'Vue', | |
}, | |
//preserveModules: true, //can set to false to get bundled file, but this is good to view what is being built | |
}, | |
}, | |
emptyOutDir: false, // to retain the types folder generated by tsc | |
}, | |
resolve: { | |
alias: { | |
'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'), | |
}, | |
}, | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment