Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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,
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");
});
}
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',