persea-old/.neutrinorc.server.js
2020-07-03 18:41:40 -05:00

87 lines
1.8 KiB
JavaScript

const {join} = require('path');
const {spawn} = require('child_process');
const copy = require('@neutrinojs/copy');
const node = require('@neutrinojs/node');
const {DefinePlugin} = require('webpack');
const {afterPlatform, initial} = require('./middleware');
if (!process.argv.find((arg) => arg === 'production')) {
spawn(
'docker',
[
'run',
'--name',
'perseadev_redis',
'-p',
'11346:6379',
'redis'
],
{stdio: 'inherit'}
);
spawn(
'docker',
[
'run',
'--name',
'perseadev_mariadb',
'-p',
'11347:6379',
'-v',
[
join(__dirname, 'var/lib/mariadb'),
'/var/lib/mysql',
].join(':'),
'-e',
'MYSQL_ROOT_PASSWORD=UNSAFE_DEV_PASSWORD',
'mariadb:10',
],
{stdio: 'inherit'}
);
}
module.exports = {
options: {
root: __dirname,
},
use: [
initial({
environmentDefines: ['REDIS_ORIGIN'],
rawScwpPaths: [
`${__dirname}/../humus/src/common`,
`${__dirname}/../humus/src/server`,
],
scwpPaths: [
/^@avocado/,
],
}),
node(),
afterPlatform({
babelPaths: [
/^@avocado/,
],
externalMatcher: /(?:@avocado|@pixi|scwp|webpack)/,
}),
(neutrino) => {
neutrino.config
.plugin('avocado-define')
.use(DefinePlugin, [
{
AVOCADO_CLIENT: false,
AVOCADO_SERVER: true,
},
]);
},
],
};
if (!process.argv.find((arg) => arg === 'production')) {
process.on('SIGINT', function() {
['redis', 'mariadb'].forEach((name) => spawn('docker', ['rm', '-f', `perseadev_${name}`]));
});
process.on('beforeExit', function() {
['redis', 'mariadb'].forEach((name) => spawn('docker', ['rm', '-f', `perseadev_${name}`]));
});
}