Skip to content

Commit

Permalink
swap webpack for esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
mscno committed Feb 1, 2024
1 parent 07e9596 commit 362e5d5
Show file tree
Hide file tree
Showing 5 changed files with 4,486 additions and 10,025 deletions.
39 changes: 39 additions & 0 deletions bundle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const esbuild = require('esbuild');
const path = require('path');
const fs = require('fs');

// Define the entry point
const entryPoint = './src/js/L.PM.js';

// Define the output directory
const outdir = path.resolve(__dirname, 'dist');
fs.mkdirSync(outdir, { recursive: true });

// Define an async function to handle the build
async function build() {
try {
await esbuild.build({
entryPoints: [entryPoint],
bundle: true,
minify: true,
sourcemap: false,
outdir,
loader: {
'.js': 'jsx',
'.css': 'css',
'.svg': 'dataurl',
},
});

// Copy the leaflet-geoman.d.ts file
fs.copyFileSync('leaflet-geoman.d.ts', path.join(outdir, 'leaflet-geoman.d.ts'));
fs.renameSync(path.join(outdir, 'L.PM.js'), path.join(outdir, 'leaflet-geoman.min.js'));
fs.renameSync(path.join(outdir, 'L.PM.css'), path.join(outdir, 'leaflet-geoman.css'));
} catch (error) {
console.error(error);
process.exit(1);
}
}

// Call the build function
build();
Loading

0 comments on commit 362e5d5

Please sign in to comment.