react-fa-picker
Version:
A reusable React Icon Picker component, bundled with its own Tailwind CSS build.
56 lines (53 loc) • 1.39 kB
text/typescript
import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import dts from "vite-plugin-dts";
export default defineConfig({
plugins: [
react(),
tailwindcss(),
dts({
insertTypesEntry: true,
tsconfigPath: "tsconfig.build.json",
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
// Bundle CSS into JS so consumers automatically get styles
cssCodeSplit: false,
lib: {
entry: path.resolve(__dirname, "src/components/icon-picker/index.tsx"),
name: "IconPicker",
// Output filenames: fc-react-icon-picker.es.js & fc-react-icon-picker.cjs.js
fileName: (format) => `app.${format}.js`,
formats: ["es", "cjs"],
},
rollupOptions: {
// Keep peer dependencies external
external: [
"react",
"react-dom",
"tailwindcss",
"postcss",
"autoprefixer",
],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
}, // Rename extracted CSS file to 'style.css'
assetFileNames: (assetInfo) => {
if (assetInfo.name && assetInfo.name.endsWith(".css")) {
return "style.css";
}
return assetInfo.name!;
},
},
},
},
});