index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
path: root/server.cjs
diff options
Diffstat (limited to 'server.cjs')
-rw-r--r-- | server.cjs | 86 |
1 files changed, 3 insertions, 83 deletions
@@ -1,92 +1,14 @@ const { createServer } = require('esbuild-server'); -const fs = require('node:fs'); const path = require('node:path'); -// 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'))) - -let version; - -const svgUseCacheBust = { - name: 'svgUseCacheBust', +const resolveImportedSvg = { + name: 'resolveImportedSvg', setup(build) { - // build.onStart(() => { - // version = Math.random(); - // console.log('svg use cache bust online', version); - // const file = fs.readFileSync('./public/assets/images/scenario-side_show.svg', {encoding: 'utf-8'}); - // console.log('file', file); - // }); - - // version = Math.random(); build.onResolve({ filter: /\.svg$/ }, args => { return { path: path.resolve('public', args.path), }; }); - - build.onEnd(result => { - // console.log('metafile', JSON.stringify(result.metafile, null, 2)); - - // for (k in result.metafile.outputs) { - // console.log(result.metafile.outputs[k]); - // } - - // const filename = Object.keys(result.metafile.outputs).find(key => { - // return result.metafile.outputs[key].inputs['public/assets/images/scenario-side_show.svg']; - // }); - - // console.log('filename', filename); - - // const file = fs.readFileSync(filename, { encoding: 'utf-8' }); - - // const mapsheets = Object.keys(result.metafile.outputs).find(key => { - // return result.metafile.outputs[key].inputs['public/assets/images/mapsheets.svg']; - // }); - - // console.log('mapsheets', path.basename(mapsheets)); - - // const newFile = file.replaceAll('mapsheets.svg', path.basename(mapsheets)); - - // fs.writeFileSync(filename, newFile); - }); } } @@ -97,11 +19,10 @@ const server = createServer( 'env': `"${process.env.NODE_ENV || 'dev'}"`, }, entryPoints: ['src/*.js'], - // outdir: 'build', ...(process.env.NODE_ENV !== 'test') && { outdir: 'build' }, - plugins: [svgUseCacheBust], + plugins: [resolveImportedSvg], loader: { '.svg': 'file' }, @@ -109,7 +30,6 @@ const server = createServer( assetNames: 'assets/images/[name]-[hash]', }, { - // http: { IncomingMessage: Request }, static: 'public', ...(process.env.NODE_ENV === 'test') && { port: 3005, |