-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
34 lines (32 loc) · 928 Bytes
/
vite.config.ts
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
import { PluginOption, defineConfig } from 'vite'
import { exec } from 'child_process'
function purescriptPlugin(): PluginOption {
return {
name: 'purescript-watch',
handleHotUpdate({ file, server }) {
if (file.endsWith('.purs')) {
console.log('PureScript file updated')
const command =
'spago bundle --platform browser --bundle-type module --source-maps --minify --outfile=src/pure.js'
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`)
return
}
if (stderr) {
console.error(`Stderr: ${stderr}`)
return
}
console.log(`Stdout: ${stdout}`)
server.ws.send({
type: 'full-reload',
path: '*',
})
})
}
},
}
}
export default defineConfig({
plugins: [purescriptPlugin()],
})