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');
|
2023-04-24 23:39:59 -06:00
|
|
|
// eslint-disable-next-line n/no-unpublished-require
|
2022-02-15 16:17:14 -07:00
|
|
|
const nodemon = require('nodemon');
|
|
|
|
|
2023-04-07 12:17:46 -06:00
|
|
|
const buildClient = require('../build-scripts/build-client');
|
2022-02-15 16:17:14 -07:00
|
|
|
|
2022-06-07 19:27:22 -06:00
|
|
|
// Build the client-side JavaScript bundle when we see any changes
|
2022-09-08 00:30:04 -06:00
|
|
|
buildClient({
|
|
|
|
build: {
|
|
|
|
// Rebuild when we see changes
|
2022-09-20 15:02:09 -06:00
|
|
|
// https://rollupjs.org/guide/en/#watch-options
|
2022-09-08 00:30:04 -06:00
|
|
|
watch: true,
|
|
|
|
},
|
|
|
|
});
|
2022-02-23 20:25:05 -07:00
|
|
|
|
2023-04-24 22:50:53 -06:00
|
|
|
const nodeArgs = [];
|
|
|
|
if (process.argv.inspectNode) {
|
|
|
|
nodeArgs.push('--inspect');
|
|
|
|
}
|
|
|
|
if (process.argv.traceWarningsNode) {
|
|
|
|
nodeArgs.push('--trace-warnings');
|
|
|
|
}
|
|
|
|
|
2022-09-02 19:49:06 -06:00
|
|
|
// Pass through some args
|
2022-07-14 10:08:50 -06:00
|
|
|
const args = [];
|
2023-04-24 22:50:53 -06:00
|
|
|
if (process.argv.tracing) {
|
2022-07-14 10:08:50 -06:00
|
|
|
args.push('--tracing');
|
|
|
|
}
|
|
|
|
|
2023-04-24 22:50:53 -06:00
|
|
|
if (process.argv.logOutputFromChildProcesses) {
|
|
|
|
args.push('--logOutputFromChildProcesses');
|
|
|
|
}
|
|
|
|
|
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,
|
2023-04-24 22:50:53 -06:00
|
|
|
nodeArgs,
|
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}`);
|
|
|
|
});
|