-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.mjs
More file actions
72 lines (71 loc) · 2.32 KB
/
vite.config.mjs
File metadata and controls
72 lines (71 loc) · 2.32 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
61
62
63
64
65
66
67
68
69
70
71
72
import { defineConfig } from 'vite';
import path from 'path';
import fs from 'fs/promises';
import { viteStaticCopy } from 'vite-plugin-static-copy';
export default defineConfig({
root: 'resources',
base: '/assets/',
assetsInclude: ['**/*.png', '**/*.jpg', '**/*.svg', '**/*.gif', '**/*.woff', '**/*.woff2', '**/*.ttf', '**/*.eot'],
build: {
outDir: '../public/assets',
emptyOutDir: true,
manifest: true,
rollupOptions: {
input: {
'js/main.js': path.resolve('resources/js/main.js'),
'css/main.css': path.resolve('resources/css/main.css'),
'css/custom.css': path.resolve('resources/css/custom.css'),
'css/admin.css': path.resolve('resources/css/admin.css'),
'css/styles.scss': path.resolve('resources/scss/styles.scss'),
},
output: {
assetFileNames: (assetInfo) => {
const ext = path.extname(assetInfo.name);
if (ext === '.css') return 'style-[hash][extname]';
return '[name]-[hash][extname]';
},
entryFileNames: '[name]-[hash].js',
chunkFileNames: 'chunk-[name]-[hash].js',
}
}
},
plugins: [
viteStaticCopy({
targets: [
{
src: 'img',
dest: ''
}
]
}),
{
name: 'move-manifest',
closeBundle: async () => {
const oldPath = path.resolve('public/assets/.vite/manifest.json');
const newPath = path.resolve('public/assets/manifest.json');
try {
await fs.rename(oldPath, newPath);
} catch (e) {
console.warn('⚠️ Не удалось переместить manifest.json', e.message);
}
}
}
],
server: {
host: true,
port: 5173,
strictPort: true
},
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: [
'import',
'mixed-decls',
'color-functions',
'global-builtin',
],
},
},
},
});