forked from Barata-Ribeiro/vite-vanilla-js-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
48 lines (42 loc) · 1.17 KB
/
vite.config.js
File metadata and controls
48 lines (42 loc) · 1.17 KB
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 { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import eslint from 'vite-plugin-eslint';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default defineConfig({
publicDir: 'public',
root: './',
build: {
outDir: 'dist',
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
},
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
const modulePath = id.split('node_modules/')[1];
const topLevelFolder = modulePath?.split('/')[0];
if (!topLevelFolder) {
const scopedPackageName = modulePath?.split('/')[1];
return scopedPackageName?.split('@')[
scopedPackageName.startsWith('@') ? 1 : 0
];
}
return topLevelFolder;
}
return null;
},
},
},
minify: 'esbuild',
},
plugins: [
eslint({
cache: false,
fix: true,
include: ['src/**/*.js', 'src/**/*.mjs', 'src/**/*.cjs', 'src/**/*.ts'],
exclude: ['node_modules', 'dist', 'build'],
}),
],
});