2022-02-15 16:17:14 -07:00
|
|
|
'use strict';
|
2022-02-15 20:33:31 -07:00
|
|
|
|
2022-02-15 16:17:14 -07:00
|
|
|
const path = require('path');
|
|
|
|
const nodemon = require('nodemon');
|
|
|
|
const { build } = require('vite');
|
|
|
|
const mergeOptions = require('merge-options');
|
|
|
|
|
|
|
|
const viteConfig = require('../vite.config');
|
|
|
|
|
2022-02-15 16:30:30 -07:00
|
|
|
// Listen for any changes to files and restart the Node.js server process
|
|
|
|
//
|
|
|
|
// For API docs, see
|
|
|
|
// https://github.com/remy/nodemon/blob/main/doc/requireable.md
|
2022-02-15 16:17:14 -07:00
|
|
|
nodemon({
|
|
|
|
script: path.join(__dirname, './server.js'),
|
|
|
|
ext: 'js json',
|
2022-02-15 16:30:30 -07:00
|
|
|
ignore: [path.join(__dirname, '../dist/*')],
|
2022-02-15 16:17:14 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
nodemon
|
|
|
|
.on('start', function () {
|
|
|
|
console.log('App has started');
|
|
|
|
})
|
|
|
|
.on('quit', function () {
|
|
|
|
console.log('App has quit');
|
|
|
|
process.exit();
|
|
|
|
})
|
|
|
|
.on('restart', function (files) {
|
|
|
|
console.log('App restarted due to: ', files);
|
|
|
|
});
|
|
|
|
|
2022-02-15 16:30:30 -07:00
|
|
|
// Build the client-side JavaScript bundle when we see any changes
|
2022-02-15 16:17:14 -07:00
|
|
|
build(
|
|
|
|
mergeOptions(viteConfig, {
|
|
|
|
build: {
|
2022-02-15 16:30:30 -07:00
|
|
|
// Rebuild when we see changes
|
2022-02-15 16:17:14 -07:00
|
|
|
watch: true,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|