humus-old/webpack.common.config.js
2019-09-22 18:45:52 -05:00

95 lines
2.3 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
const isProduction = !!process.argv.find((arg) => '--production' === arg);
const config = {
mode: isProduction ? 'production' : 'development',
module: {
rules: [
{
test: /\.js$/,
exclude: [
/(node_modules\/(?!@avocado|contempo))/,
],
use: {
loader: 'babel-loader',
options: {},
},
},
{
test: /register-packets\.js$/,
use: {
loader: './defgen',
options: {
classTransformer: (Packet) => {
return `${Packet}Packet`;
},
paths: [
path.resolve(__dirname, 'common'),
],
registrar: {
function: 'registerPacket',
module: '@avocado/net',
},
type: 'packet',
},
},
},
{
test: /register-synchronizeds\.js$/,
use: {
loader: './defgen',
options: {
paths: [
path.resolve(__dirname, 'common'),
],
registrar: {
function: 'registerSynchronized',
module: '@avocado/net',
},
type: 'synchronized',
},
},
},
{
test: /register-traits\.js$/,
use: {
loader: './defgen',
options: {
paths: [
path.resolve(__dirname, 'common'),
],
registrar: {
function: 'registerTrait',
module: '@avocado/entity',
},
type: 'trait',
},
},
},
],
},
output: {
// Worker happiness.
globalObject: `(typeof self === 'undefined' ? this : self)`,
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
plugins: [],
resolve: {
alias: {
'register-packets': path.join(__dirname, 'register-packets'),
'register-synchronizeds': path.join(__dirname, 'register-synchronizeds'),
'register-traits': path.join(__dirname, 'register-traits'),
},
modules: [path.resolve(__dirname, 'node_modules')],
},
resolveLoader: {
modules: [path.resolve(__dirname, 'node_modules')],
},
};
module.exports = config;