diff --git a/package.json b/package.json index 2357f3b..e660010 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,15 @@ "type": "git", "url": "https://github.com/arifszn/gitprofile.git" }, + "files": ["dist"], + "main": "./dist/my-lib.umd.js", + "module": "./dist/my-lib.es.js", + "exports": { + ".": { + "import": "./dist/my-lib.es.js", + "require": "./dist/my-lib.umd.js" + } + }, "scripts": { "dev": "vite", "build": "vite build", diff --git a/src/App.jsx b/src/App.jsx index dd2b845..f941509 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -13,6 +13,7 @@ import Project from './components/project'; import Blog from './components/blog'; import { getInitialTheme, setupHotjar } from './helpers/utils'; import config from '../gitprofile.config'; +import './assets/index.css'; function App() { const [theme, setTheme] = useState(getInitialTheme()); diff --git a/src/index.css b/src/assets/index.css similarity index 100% rename from src/index.css rename to src/assets/index.css diff --git a/src/main.jsx b/src/main.jsx index d88f50c..5c33570 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -1,6 +1,5 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import './index.css'; import App from './App'; import { HelmetProvider } from 'react-helmet-async'; diff --git a/vite.config.js b/vite.config.js index ff568c7..515c326 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,7 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import postcss from './postcss.config.js'; +import path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ @@ -11,4 +12,16 @@ export default defineConfig({ css: { postcss, }, + build: { + lib: { + entry: path.resolve(__dirname, 'src/App.jsx'), + name: 'MyLib', + fileName: (format) => `my-lib.${format}.js`, + }, + rollupOptions: { + // make sure to externalize deps that shouldn't be bundled + // into your library + external: ['react', 'react-dom'], + }, + }, });