2019-03-20 15:28:18 -05:00
|
|
|
const path = require('path');
|
|
|
|
|
2019-04-20 14:16:06 -05:00
|
|
|
const webpack = require('webpack');
|
2019-03-20 15:28:18 -05:00
|
|
|
const nodeExternals = require('webpack-node-externals');
|
|
|
|
const StartServerPlugin = require('start-server-webpack-plugin');
|
|
|
|
|
|
|
|
const config = require('./webpack.common.config');
|
2019-09-30 23:38:44 -05:00
|
|
|
const isProduction = !!process.argv.find((arg) => '--production' === arg);
|
2019-03-20 15:28:18 -05:00
|
|
|
|
2019-09-30 23:38:44 -05:00
|
|
|
if (!isProduction) {
|
|
|
|
config.devtool = 'source-map';
|
|
|
|
}
|
2019-03-20 15:28:18 -05:00
|
|
|
config.entry = {
|
|
|
|
server: [
|
|
|
|
'source-map-support/register',
|
|
|
|
'@babel/polyfill',
|
2019-04-14 21:32:48 -05:00
|
|
|
path.join(__dirname, 'register-packets.js'),
|
2019-09-22 18:45:52 -05:00
|
|
|
path.join(__dirname, 'register-synchronizeds.js'),
|
2019-04-09 09:43:45 -05:00
|
|
|
'@avocado/behavior/item/initialize',
|
2019-03-20 22:23:26 -05:00
|
|
|
path.join(__dirname, 'server', 'index.js'),
|
2019-03-20 15:28:18 -05:00
|
|
|
],
|
|
|
|
};
|
2019-04-30 18:22:19 -05:00
|
|
|
if (process.argv.find((arg) => '--hot' === arg)) {
|
|
|
|
config.entry.server.unshift('webpack/hot/signal');
|
|
|
|
}
|
2019-03-20 15:28:18 -05:00
|
|
|
config.externals = [
|
|
|
|
nodeExternals({
|
2019-04-20 14:16:06 -05:00
|
|
|
whitelist: /(?:@avocado|webpack\/hot\/signal)/,
|
2019-03-20 15:28:18 -05:00
|
|
|
}),
|
|
|
|
];
|
2019-05-05 17:03:15 -05:00
|
|
|
// Babel config file.
|
|
|
|
config.module.rules[0].use.options.configFile = path.resolve(
|
|
|
|
__dirname, 'babel.server.config.js'
|
|
|
|
);
|
2019-04-14 20:39:27 -05:00
|
|
|
config.module.rules[1].use.options.paths.push(
|
|
|
|
path.resolve(__dirname, 'server'),
|
|
|
|
);
|
2019-04-14 21:32:48 -05:00
|
|
|
config.module.rules[2].use.options.paths.push(
|
|
|
|
path.resolve(__dirname, 'server'),
|
|
|
|
);
|
2019-09-22 18:45:52 -05:00
|
|
|
config.module.rules[3].use.options.paths.push(
|
|
|
|
path.resolve(__dirname, 'server'),
|
|
|
|
);
|
2019-05-25 09:12:18 -05:00
|
|
|
const nodeArgs = ['--preserve-symlinks'];
|
2019-10-03 00:31:09 -05:00
|
|
|
if (process.argv.find((arg) => '--inspect' === arg)) {
|
|
|
|
nodeArgs.push('--inspect');
|
|
|
|
}
|
2019-04-12 13:44:56 -05:00
|
|
|
if (process.argv.find((arg) => '--prof' === arg)) {
|
|
|
|
nodeArgs.push('--prof');
|
|
|
|
}
|
2019-04-30 18:22:19 -05:00
|
|
|
if (process.argv.find((arg) => '--autorun' === arg)) {
|
|
|
|
config.plugins.push(new StartServerPlugin({
|
|
|
|
name: 'server.js',
|
|
|
|
nodeArgs: nodeArgs,
|
|
|
|
signal: true,
|
|
|
|
}));
|
|
|
|
}
|
2019-04-22 21:03:16 -05:00
|
|
|
config.plugins.push(new webpack.DefinePlugin({
|
|
|
|
AVOCADO_CLIENT: false,
|
|
|
|
AVOCADO_SERVER: true,
|
|
|
|
}));
|
2019-03-20 15:28:18 -05:00
|
|
|
config.target = 'node';
|
|
|
|
|
|
|
|
module.exports = config;
|