2022-02-15 16:17:14 -07:00
|
|
|
'use strict';
|
2022-02-15 20:33:31 -07:00
|
|
|
|
2022-06-07 19:27:22 -06:00
|
|
|
console.log('start-dev process.env.NODE_ENV', process.env.NODE_ENV);
|
|
|
|
|
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-06-07 19:27:22 -06:00
|
|
|
// Build the client-side JavaScript bundle when we see any changes
|
|
|
|
build(
|
|
|
|
mergeOptions(viteConfig, {
|
|
|
|
build: {
|
|
|
|
// Rebuild when we see changes
|
|
|
|
watch: true,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
2022-02-23 20:25:05 -07:00
|
|
|
|
2022-07-14 10:08:50 -06:00
|
|
|
const args = [];
|
|
|
|
if (process.argv.includes('--tracing')) {
|
|
|
|
args.push('--tracing');
|
|
|
|
}
|
|
|
|
|
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-16 13:55:52 -07:00
|
|
|
ignoreRoot: ['.git'],
|
2022-02-15 16:30:30 -07:00
|
|
|
ignore: [path.join(__dirname, '../dist/*')],
|
2022-07-14 10:08:50 -06:00
|
|
|
args,
|
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-06-07 19:27:22 -06:00
|
|
|
.on('crash', function () {
|
|
|
|
console.log('Nodemon: script crashed for some reason');
|
|
|
|
})
|
|
|
|
// .on('watching', (file) => {
|
|
|
|
// console.log('watching');
|
|
|
|
// })
|
|
|
|
.on('log', function (data) {
|
|
|
|
console.log(`Nodemon logs: ${data.type}: ${data.message}`);
|
|
|
|
});
|