humus-old/webpack.server.config.js
2019-04-22 21:03:16 -05:00

47 lines
1.1 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const StartServerPlugin = require('start-server-webpack-plugin');
const config = require('./webpack.common.config');
config.devtool = 'inline-source-map';
config.entry = {
server: [
'webpack/hot/signal',
'source-map-support/register',
'@babel/polyfill',
path.join(__dirname, 'register-packets.js'),
'@avocado/behavior/item/initialize',
path.join(__dirname, 'server', 'index.js'),
],
};
config.externals = [
nodeExternals({
whitelist: /(?:@avocado|webpack\/hot\/signal)/,
}),
];
config.module.rules[1].use.options.paths.push(
path.resolve(__dirname, 'server'),
);
config.module.rules[2].use.options.paths.push(
path.resolve(__dirname, 'server'),
);
const nodeArgs = [];
if (process.argv.find((arg) => '--prof' === arg)) {
nodeArgs.push('--prof');
}
config.plugins.push(new StartServerPlugin({
name: 'server.js',
nodeArgs: nodeArgs,
signal: true,
}));
config.plugins.push(new webpack.DefinePlugin({
AVOCADO_CLIENT: false,
AVOCADO_SERVER: true,
}));
config.target = 'node';
module.exports = config;