2019-03-20 15:28:18 -05:00
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const webpack = require('webpack');
|
|
|
|
|
2019-05-05 04:27:18 -05:00
|
|
|
const isProduction = !!process.argv.find((arg) => '--production' === arg);
|
|
|
|
|
2019-03-20 15:28:18 -05:00
|
|
|
const config = {
|
2019-05-05 04:27:18 -05:00
|
|
|
mode: isProduction ? 'production' : 'development',
|
2019-03-20 15:28:18 -05:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: [
|
2019-04-12 11:04:59 -05:00
|
|
|
/(node_modules\/(?!@avocado|contempo))/,
|
2019-03-20 15:28:18 -05:00
|
|
|
],
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
},
|
|
|
|
},
|
2019-04-14 21:32:48 -05:00
|
|
|
{
|
2019-04-25 00:09:28 -05:00
|
|
|
test: /register-packets\.js$/,
|
2019-04-14 21:32:48 -05:00
|
|
|
use: {
|
|
|
|
loader: './defgen',
|
|
|
|
options: {
|
|
|
|
classTransformer: (Packet) => {
|
|
|
|
return `${Packet}Packet`;
|
|
|
|
},
|
|
|
|
paths: [
|
|
|
|
path.resolve(__dirname, 'common'),
|
|
|
|
],
|
|
|
|
registrar: {
|
|
|
|
function: 'registerPacket',
|
2019-04-24 18:02:13 -05:00
|
|
|
module: '@avocado/net',
|
2019-04-14 21:32:48 -05:00
|
|
|
},
|
|
|
|
type: 'packet',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-20 15:28:18 -05:00
|
|
|
{
|
2019-04-25 00:09:28 -05:00
|
|
|
test: /register-traits\.js$/,
|
2019-04-14 20:39:27 -05:00
|
|
|
use: {
|
2019-04-14 21:06:58 -05:00
|
|
|
loader: './defgen',
|
2019-04-14 20:39:27 -05:00
|
|
|
options: {
|
|
|
|
paths: [
|
|
|
|
path.resolve(__dirname, 'common'),
|
|
|
|
],
|
2019-04-14 21:06:58 -05:00
|
|
|
registrar: {
|
|
|
|
function: 'registerTrait',
|
2019-04-14 21:32:48 -05:00
|
|
|
module: '@avocado/entity',
|
2019-04-14 21:06:58 -05:00
|
|
|
},
|
|
|
|
type: 'trait',
|
|
|
|
},
|
2019-04-14 20:39:27 -05:00
|
|
|
},
|
2019-03-20 15:28:18 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
output: {
|
2019-05-05 04:27:18 -05:00
|
|
|
// Worker happiness.
|
2019-04-25 00:09:28 -05:00
|
|
|
globalObject: `(typeof self === 'undefined' ? this : self)`,
|
2019-03-20 15:28:18 -05:00
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
filename: '[name].js',
|
|
|
|
},
|
2019-04-22 14:07:26 -05:00
|
|
|
plugins: [],
|
2019-03-20 15:28:18 -05:00
|
|
|
resolve: {
|
2019-04-25 00:09:28 -05:00
|
|
|
alias: {
|
|
|
|
'register-packets': path.resolve(__dirname, 'register-packets'),
|
|
|
|
'register-traits': path.resolve(__dirname, 'register-traits'),
|
|
|
|
},
|
2019-03-20 15:28:18 -05:00
|
|
|
modules: [path.resolve(__dirname, 'node_modules')],
|
|
|
|
},
|
|
|
|
resolveLoader: {
|
|
|
|
modules: [path.resolve(__dirname, 'node_modules')],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = config;
|