How to use esbuild - 3 common examples

To help you get started, we’ve selected a few esbuild examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cs8425 / go-bot / admin-web / web-src / esbuild.js View on Github external
// let path = require('path')

		// Redirect all 'react' to "./public/images/"
		build.onResolve({ filter: /^react$/ }, args => {
			return { path: require.resolve('preact/compat') }
		});
		build.onResolve({ filter: /^react-dom$/ }, args => {
			return { path: require.resolve('preact/compat') }
		});
	},
}

copy('./public', '../www');

console.log('start build...');
esbuild.build({
	entryPoints: ['src/main.js'],
	bundle: true,
	minify: true,
	sourcemap: false,
	sourcesContent: true,
	target: [
		'es2015',
	],
	outfile: '../www/js/main.js',
	loader: {
		'.js': 'jsx',
	},
	jsxFactory: 'h',
	jsxFragment: 'Fragment',
	plugins: [
		reactOnResolvePlugin,
github daud-io / daud / Game.Engine / wwwroot / build.js View on Github external
function runBuild() {
    build({
        stdio: "inherit",
        entryPoints: ["./src/game.ts"],
        outfile: "dist/main.js",
        sourcemap: true,
        bundle: true,
        minifyWhitespace: prod,
        minifySyntax: prod,
        define: { global: "window" },
    }).then(() => {
        console.log("Wrote to dist/main.js");
    });
}
github cs8425 / go-bot / admin-web / web-src / esbuild-dev.js View on Github external
build.onResolve({ filter: /^react$/ }, args => {
			return {
				path: require.resolve('preact/compat'),
				external: false,
			}
		});
		build.onResolve({ filter: /^react-dom$/ }, args => {
			return {
				path: require.resolve('preact/compat'),
				external: false,
			}
		});
	},
}

esbuild.serve({
	servedir: 'public',
	port: config.internalPort,
}, {
	entryPoints: ['src/main.js'],
	bundle: true,
	sourcemap: true,
	sourcesContent: true,
	target: [
		'es2015',
	],
	outfile: 'public/js/main.js',
	loader: {
		'.js': 'jsx',
	},
	jsxFactory: 'h',
	jsxFragment: 'Fragment',

esbuild

An extremely fast JavaScript and CSS bundler and minifier.

MIT
Latest version published 1 day ago

Package Health Score

86 / 100
Full package analysis

Popular esbuild functions