forked from devstrons/heloworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
61 lines (56 loc) · 1.74 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
/*
* Vite bundler configuration for hello-world project.
* Created On 26 August 2021
*/
import autoprefixer from 'autoprefixer'
import inlineSVG from 'posthtml-inline-svg'
import modules from 'posthtml-modules'
import tailwindcss from 'tailwindcss'
import { defineConfig } from 'vite'
import fullReload from 'vite-plugin-full-reload'
import { minifyHtml } from 'vite-plugin-html'
import { posthtmlPlugin } from 'vite-plugin-posthtml'
export default ({ mode }) =>
defineConfig({
esbuild: true,
clearScreen: false,
publicDir: '../public',
build: {
emptyOutDir: true,
outDir: '../dist',
},
server: {
port: 3000,
fs: {
strict: false,
},
},
css: {
postcss: {
plugins: [tailwindcss(), autoprefixer()],
},
},
plugins: [
// run PostHTML to construct the single-page HTML file
posthtmlPlugin({
plugins: [
// render other HTML files as modules
modules({
root: 'src',
}),
// inline SVGs wherever
// required straight into HTML
inlineSVG({
cwd: 'src/sections',
tag: 'vector',
attr: 'src',
}),
],
}),
// minify html during production
mode == 'production' ? minifyHtml() : null,
// fully reload the page if any of the component
// HTML files are changed
fullReload.default(['src/sections/**/*.html']),
],
})