Web Dev Solutions

Catalin Mititiuc

const { createServer } = require('esbuild-server'); // const { IncomingMessage } = require('node:http'); // const { URL } = require('node:url'); // const path = require('node:path'); // class Request extends IncomingMessage { // constructor(socket) { // super(socket); // } // get url() { // console.log('getter called', this._url); // return this._url; // } // set url(val) { // console.log('setter called', val); // this._url = val; // } // } // const propDesc = Object.getOwnPropertyDescriptor(URL.prototype, 'pathname'); // // console.log('propDesc before', propDesc); // Object.defineProperty(URL.prototype, 'pathname', { // __proto__: null, // get: function() { // const pathname = propDesc.get.call(this); // console.log('get pathname', path.normalize(path.join('public', pathname))); // return pathname; // }, // // set: function(val) { // // console.log('set pathname', val); // // propDesc.set.call(this, val); // // // this._pathname = val; // // }, // }); // console.log('path', path.normalize(path.join('public', 'assets/css/damage_block.css'))) const server = createServer( { bundle: true, define: { 'env': `"${process.env.NODE_ENV || 'dev'}"`, }, entryPoints: ['src/index.js', 'src/map.js', 'src/soldier_record_block.js'], // outdir: 'build', ...(process.env.NODE_ENV !== 'test') && { outdir: 'build' }, // loader: { // '.svg': 'file' // }, }, { // http: { IncomingMessage: Request }, static: 'public', ...(process.env.NODE_ENV === 'test') && { port: 3005, injectLiveReload: false, watch: false } } ); const buildStart = Date.now(); server .start() .then((d) => { console.log(`Build completed in ${Date.now() - buildStart}ms`); }) .catch(() => { console.error('Build failed'); }); console.log(`${process.env.NODE_ENV === 'test' ? 'Test' : 'Development'} server running at ${server.url}`);