-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.js
59 lines (55 loc) · 2.2 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
// https://www.npmjs.com/package/vite-plugin-restart
import ViteRestart from 'vite-plugin-restart';
// defaults, local DDEV
let port = 5173;
let origin = `${process.env.DDEV_PRIMARY_URL}:${port}`;
// Gitpod support
// env var GITPOD_WORKSPACE_URL needs to be passed through to ddev, see .ddev/config.yaml
if (Object.prototype.hasOwnProperty.call(process.env, 'GITPOD_WORKSPACE_URL')) {
origin = `${process.env.GITPOD_WORKSPACE_URL}`;
origin = origin.replace('https://', 'https://5173-');
console.log(`Gitpod detected, set origin to ${origin}`);
}
// Codespaces support
// env var GITPOD_WORKSPACE_URL needs to be passed through to ddev, see .ddev/config.yaml
// You need to switch the port manually to public on codespaces after launching
if (Object.prototype.hasOwnProperty.call(process.env, 'CODESPACES')) {
origin = `https://${process.env.CODESPACE_NAME}-${port}.${process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}`;
console.log('Codespaces environment detected, setting config to ', {port,origin});
console.log("Please check that this can be opened via browser after you run 'ddev npm run dev':");
console.log(origin + '/src/js/app.js');
console.log('If it can\'t be opened, please switch the Vite port to public in the ports tab.');
/* console.log({
'CODESPACES' : process.env?.CODESPACES,
'CODESPACE_NAME' : process.env?.CODESPACE_NAME,
'GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN': process.env?.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN
});*/
}
export default ({ command }) => ({
// 'vite' is always command = 'serve', other command is 'build'
base: command === 'serve' ? '' : '/dist/',
build: {
manifest: true,
outDir: 'web/dist/',
rollupOptions: {
input: {
app: './src/js/app.js',
}
},
},
// adjustments for ddev:
server: {
// respond to all network requests:
host: '0.0.0.0',
port: port,
strictPort: true,
// origin is important, see https://nystudio107.com/docs/vite/#vite-processed-assets
origin: origin,
},
plugins: [
ViteRestart({
restart: [
'./templates/**/*',
],
})]
});