forked from htmlacademy/accelerator-project-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
72 lines (71 loc) · 1.9 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
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 { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
import VitePluginSvgSpritemap from '@spiriit/vite-plugin-svg-spritemap';
// import { ViteMinifyPlugin } from 'vite-plugin-minify';
/** @type {import('vite').UserConfig} */
export default {
plugins: [
VitePluginSvgSpritemap('source/img/sprite/*.svg', {
styles: false,
injectSVGOnDev: true,
}),
// input https://www.npmjs.com/package/html-minifier-terser options
// ViteMinifyPlugin({}),
ViteImageOptimizer({
test: /\.(jpe?g|png|svg)$/i,
includePublic: false,
logStats: true,
ansiColors: true,
svg: {
multipass: true,
plugins: [
{
name: 'preset-default',
params: {
overrides: {
cleanupNumericValues: false,
convertPathData: {
floatPrecision: 2,
forceAbsolutePath: false,
utilizeAbsolute: false,
},
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
cleanupIds: false,
},
},
},
'removeDimensions',
],
},
png: {
// https://sharp.pixelplumbing.com/api-output#png
quality: 80,
palette: true
},
jpeg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
quality: 80,
progressive: true
},
jpg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
quality: 80,
progressive: true
},
// Cache assets in cacheLocation. When enabled, reads and writes asset files with their hash suffix from the specified path.
cache: true,
cacheLocation: './.cache',
}),
],
css: {
devSourcemap: true
},
publicDir: 'public',
root: './source',
build: {
outDir: '../dist',
},
base: './',
server: {
port: 3000,
}
};