-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
48 lines (45 loc) · 1.93 KB
/
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
41
42
43
44
45
46
47
48
import CbnCustomCodeSync from '@combeenation/vite-plugin-custom-code-sync';
import { resolve } from 'path';
import { defineConfig } from 'vite';
// TODO: Check, if we can somehow get rid of the ignore. `__dirname` is defined at runtime as there's no error when
// building etc. but ESLint doesn't seem to know that.
// Get rid of `dirName` var, when this is resolved and use `__dirname` directly where needed...
// eslint-disable-next-line no-undef
const dirName = __dirname;
export default ({ mode }) => {
const colorGreen = '42;30';
const colorizedMode = `\x1b[${colorGreen}m ${mode} \x1b[0m`;
console.log('------------------------------------------------------------------------------------------');
console.log(`Building in ${colorizedMode} mode`);
console.log('------------------------------------------------------------------------------------------');
console.log('');
return defineConfig({
plugins: [CbnCustomCodeSync()],
build: {
rollupOptions: {
input: {
main: resolve(dirName, 'src/index.ts'),
},
output: {
entryFileNames: 'cfgr.js',
// "iife" output format suits best for the use case as bundled application in a `script` tag according to
// [the docs](https://rollupjs.org/configuration-options/#output-format).
// "cjs" format has been used as well, but it leads to errors like "Identifier 'AI' has already been declared"
// at run time for certain, typically more complex, applications.
// Test carefully when touching this setting!
format: 'iife',
},
external: ['tippy.js'],
globals: {
'tippy.js': 'tippy',
},
},
sourcemap: true,
},
server: {
// The default `true` causes some unwanted side effects and we're not using HMR anyhow ATM.
// More details: https://combeenation.youtrack.cloud/issue/CB-9193
hmr: false,
},
});
};