This commit is contained in:
Ariful Alam
2022-03-24 22:22:45 +06:00
parent c453eb95fd
commit 07e1e090a1
5 changed files with 23 additions and 1 deletions

View File

@@ -9,6 +9,15 @@
"type": "git", "type": "git",
"url": "https://github.com/arifszn/gitprofile.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": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",

View File

@@ -13,6 +13,7 @@ import Project from './components/project';
import Blog from './components/blog'; import Blog from './components/blog';
import { getInitialTheme, setupHotjar } from './helpers/utils'; import { getInitialTheme, setupHotjar } from './helpers/utils';
import config from '../gitprofile.config'; import config from '../gitprofile.config';
import './assets/index.css';
function App() { function App() {
const [theme, setTheme] = useState(getInitialTheme()); const [theme, setTheme] = useState(getInitialTheme());

View File

@@ -1,6 +1,5 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import './index.css';
import App from './App'; import App from './App';
import { HelmetProvider } from 'react-helmet-async'; import { HelmetProvider } from 'react-helmet-async';

View File

@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import postcss from './postcss.config.js'; import postcss from './postcss.config.js';
import path from 'path';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
@@ -11,4 +12,16 @@ export default defineConfig({
css: { css: {
postcss, 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'],
},
},
}); });