-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
60 lines (56 loc) · 1.55 KB
/
Copy pathvite.config.js
File metadata and controls
60 lines (56 loc) · 1.55 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
49
50
51
52
53
54
55
56
57
58
59
60
import { defineConfig } from 'vite';
import { glob } from 'glob';
import injectHTML from 'vite-plugin-html-inject';
import FullReload from 'vite-plugin-full-reload';
import SortCss from 'postcss-sort-media-queries';
export default defineConfig(({ command }) => {
const basePath = process.env.VITE_BASE_PATH;
const devHost = process.env.VITE_DEV_HOST;
const devPort = process.env.VITE_DEV_PORT;
return {
base: basePath,
define: {
[command === 'serve' ? 'global' : '_global']: {},
},
root: 'src',
server: {
host: devHost,
port: devPort,
open: true, // опционально — откроет браузер при старте
},
build: {
sourcemap: true,
rollupOptions: {
input: glob.sync('./src/*.html'),
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return 'vendor';
}
},
entryFileNames: chunkInfo => {
if (chunkInfo.name === 'commonHelpers') {
return 'commonHelpers.js';
}
return '[name].js';
},
assetFileNames: assetInfo => {
if (assetInfo.name && assetInfo.name.endsWith('.html')) {
return '[name].[ext]';
}
return 'assets/[name]-[hash][extname]';
},
},
},
outDir: '../dist',
emptyOutDir: true,
},
plugins: [
injectHTML(),
FullReload(['./src/**/**.html']),
SortCss({
sort: 'mobile-first',
}),
],
};
});