-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
40 lines (35 loc) · 987 Bytes
/
vite.config.js
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
38
39
40
import { resolve as pathResolve } from 'path';
import { createLogger, defineConfig, loadEnv } from 'vite';
const logger = createLogger();
const originalWarning = logger.warn;
logger.warn = (msg, options) => {
//hide browser compatibility warning
if (msg.includes('plugin:vite:resolve')) return;
originalWarning(msg, options);
};
const resolve = (path) => pathResolve(__dirname, path)
export default ({mode}) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())};
const buildExtra =
mode === 'production' ? {minify: true} : {minify: false, sourcemap: true};
return defineConfig({
customLogger: logger,
optimizeDeps: {
esbuildOptions: {
plugins: [],
},
},
build: {
...buildExtra,
emptyOutDir: true,
outDir: "dist",
lib: {
entry: {
api: resolve('./src/index.ts'),
},
formats: ["es"],
fileName: (format, entryName) => `index.js`
}
},
});
};