forked from Grafikart/Grafikart.fr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
64 lines (60 loc) · 1.34 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
// @ts-check
import prefresh from "@prefresh/vite";
import { resolve } from 'path'
const root = "./assets";
/**
* Rafraichi la page quand on modifie un fichier twig
*/
const twigRefreshPlugin = () => ({
name: 'twig-refresh',
configureServer({ watcher, ws }) {
watcher.add(resolve(__dirname, "templates/**/*.twig"));
watcher.on("change", function (path) {
if (path.endsWith(".twig")) {
ws.send({
type: 'full-reload',
})
}
});
}
})
/**
* @type { import('vite').UserConfig }
*/
const config = {
resolve: {
alias: {
react: "preact/compat",
"react-dom": "preact/compat",
}
},
emitManifest: true,
cors: true,
optimizeDeps: {
include: ['preact/hooks', 'preact/compat', 'htm/mini']
},
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
jsxInject: `import { h, Fragment } from 'preact'`
},
base: '/assets/',
build: {
polyfillDynamicImport: false,
assetsDir: '',
manifest: true,
outDir: '../public/assets/',
rollupOptions: {
output: {
manualChunks: undefined // Désactive la séparation du vendor
},
input: {
app: resolve(__dirname, 'assets/app.js'),
admin: resolve(__dirname, 'assets/admin.js')
}
},
},
plugins: [prefresh(), twigRefreshPlugin()],
root
};
module.exports = config;