-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
118 lines (113 loc) · 2.77 KB
/
vite.config.js
File metadata and controls
118 lines (113 loc) · 2.77 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import i18n from 'laravel-vue-i18n/vite';
import viteImagemin from '@vheemstra/vite-plugin-imagemin';
import sharp from 'sharp';
import { Features } from 'lightningcss';
const imageminWebp = async buffer => {
return await sharp(buffer)
.webp({
quality: 80,
lossless: false,
})
.toBuffer()
.catch((err) => {
throw new Error('imagemin-webp', { cause: err });
});
};
const imageminAvif = async buffer => {
return await sharp(buffer)
.avif({
quality: 60,
lossless: false,
speed: 5,
chromaSubsampling: '4:2:0',
})
.toBuffer()
.catch((err) => {
throw new Error('imagemin-avif', { cause: err });
});
};
export default defineConfig(({ mode }) => {
const isTest = process.env.NODE_ENV === 'test' || mode === 'test';
const conditionalPlugins = [];
if (!isTest) {
conditionalPlugins.push(laravel({
input: 'resources/js/app.ts',
ssr: 'resources/js/ssr.ts',
refresh: true,
}));
}
return ({
server: {
host: 'localhost',
},
resolve: {
alias: {
'~@picocss': resolve(__dirname, 'node_modules/@picocss'),
'~the-new-css-reset': resolve(__dirname, 'node_modules/the-new-css-reset'),
'~@fortawesome': resolve(__dirname, 'node_modules/@fortawesome'),
'~tippy.js': resolve(__dirname, 'node_modules/tippy.js'),
'@img': resolve(__dirname, 'resources/img'),
'@public': resolve(__dirname, 'public'),
'@': resolve(__dirname, 'resources/js'),
},
},
plugins: [
...conditionalPlugins,
vue(),
i18n(),
viteImagemin({
skipIfLarger: false,
plugins: {
bypass: () => [],
},
makeWebp: {
plugins: {
png: imageminWebp,
},
skipIfLargerThan: false,
},
makeAvif: {
plugins: {
png: imageminAvif,
},
skipIfLargerThan: false,
},
}),
],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('.json')) {
return id.split(/[\\\/]/g).find(el => el.includes('.json')).replace('.json', '-json');
}
return null;
},
},
},
},
css: {
lightningcss: {
exclude: Features.LightDark,
},
},
test: {
sequence: {
shuffle: true,
},
exclude: [
'**/node_modules/**',
'**/vendor/**',
],
setupFiles: ['./setup/setup.ts'],
coverage: {
provider: 'v8',
include: ['resources/js/**/*.ts'],
},
},
});
});