-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
67 lines (59 loc) · 2.04 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
import * as path from 'path';
import ViteRestart from 'vite-plugin-restart';
import checker from 'vite-plugin-checker';
import critical from 'rollup-plugin-critical';
import copy from 'rollup-plugin-copy';
const FORK_THEME_BASE_PATH = '/src/Frontend/Themes/' + path.basename(__dirname);
/**
* @type {import('vite').UserConfig}
*/
export default ({ command }) => ({
base: FORK_THEME_BASE_PATH + (command === 'serve' ? '/' : '/dist/'),
build: {
manifest: true,
outDir: './dist/',
rollupOptions: {
input: {
app: '/Core/Js/app.ts',
},
},
},
plugins: [
// Generate a legacy bundle for non-ESM native browsers
// legacy({
// targets: ['defaults', 'not IE 11'],
// }),
// Reload the Vite server when our (twig) templates changed
ViteRestart({
reload: ['Core/Layout/Templates/**/*', 'Modules/**/*'],
}),
// A Vite plugin that can run TypeScript checks in worker thread.
checker({ typescript: true }),
// Generate critical css
critical({
criticalUrl: 'https://www.fork-cms.com', // Fill in your own website
criticalBase: './dist/critical/',
criticalPages: [
{ uri: '', template: 'home' },
{ uri: '/contact', template: 'page' },
],
criticalConfig: {
width: 1400, // max breakpoint in our theme
},
}),
// Ensure a screen.css file exists (which gets loaded by the CMS)
copy({
hook: 'writeBundle',
targets: [{ src: 'dist/assets/app.*.css', dest: 'Core/Layout/Css', rename: () => 'screen.css' }],
}),
],
// We need to make a few tweaks to still serve from the local webserver
server: {
host: '0.0.0.0', // broadcast to all ipv4 addresses on the local machine (e.g. for Docker setups)
cors: true,
hmr: {
host: 'localhost',
protocol: 'ws',
},
},
});