-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
37 lines (33 loc) · 1.09 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { defineConfig } from 'vite';
import plugin from '@vitejs/plugin-react';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import { resolve } from 'path';
import { devDependencies, dependencies } from './package.json';
const IS_DEPL = process.env.IS_DEPL;
console.log("IS_DEPL", IS_DEPL)
//ref: https://miyauchi.dev/posts/lib-vite-tailwindcss/
const general = defineConfig({
plugins: [
plugin({
'jsxRuntime': 'classic'
}),
cssInjectedByJsPlugin(),
],
build: {
lib: {
entry: resolve(__dirname, 'src/lib', 'index.ts'),
formats: ['es', 'cjs'],
fileName: (ext) => `index.${ext}.js`,
},
rollupOptions: {
external: [...Object.keys(devDependencies), ...Object.keys(dependencies)] //by-default vite bundles all dependencies, so passing array of dependencies to exclude
},
target: 'esnext',
sourcemap: false
},
});
// https://vitejs.dev/config/
const depoyment = defineConfig({
plugins: [plugin()],
})
export default IS_DEPL ? depoyment : general;