feat: configurable esbuild build target (#34398)
This commit is contained in:
parent
871ae70172
commit
39b14f3a67
3 changed files with 13 additions and 1 deletions
|
|
@ -68,6 +68,10 @@ const argv = yargs
|
|||
description:
|
||||
"Skips build and uses cached build artifacts to update assets.json (used by Bench)",
|
||||
})
|
||||
.option("esbuild-target", {
|
||||
type: "string",
|
||||
description: "Specifies the target of the build output.",
|
||||
})
|
||||
.example("node esbuild --apps frappe,erpnext", "Run build only for frappe and erpnext")
|
||||
.example(
|
||||
"node esbuild --files frappe/website.bundle.js,frappe/desk.bundle.js",
|
||||
|
|
@ -82,6 +86,7 @@ const FILES_TO_BUILD = argv.files ? argv.files.split(",") : [];
|
|||
const WATCH_MODE = Boolean(argv.watch);
|
||||
const PRODUCTION = Boolean(argv.production);
|
||||
const RUN_BUILD_COMMAND = !WATCH_MODE && Boolean(argv["run-build-command"]);
|
||||
const ESBUILD_TARGET = argv["esbuild-target"] || "es2017";
|
||||
|
||||
const TOTAL_BUILD_TIME = `${chalk.black.bgGreen(" DONE ")} Total Build Time`;
|
||||
const NODE_PATHS = [].concat(
|
||||
|
|
@ -313,7 +318,7 @@ function get_build_options(files, outdir, plugins) {
|
|||
return {
|
||||
entryPoints: files,
|
||||
entryNames: "[dir]/[name].[hash]",
|
||||
target: ["es2017"],
|
||||
target: [ESBUILD_TARGET],
|
||||
outdir,
|
||||
sourcemap: true,
|
||||
bundle: true,
|
||||
|
|
|
|||
|
|
@ -228,6 +228,7 @@ def bundle(
|
|||
files=None,
|
||||
save_metafiles=False,
|
||||
using_cached=False,
|
||||
esbuild_target=None,
|
||||
):
|
||||
"""concat / minify js files"""
|
||||
setup()
|
||||
|
|
@ -239,6 +240,9 @@ def bundle(
|
|||
if apps:
|
||||
command += f" --apps {apps}"
|
||||
|
||||
if esbuild_target:
|
||||
command += f" --esbuild-target {esbuild_target}"
|
||||
|
||||
if skip_frappe:
|
||||
command += " --skip_frappe"
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ def build(
|
|||
|
||||
# don't minify in developer_mode for faster builds
|
||||
development = frappe.local.conf.developer_mode or frappe._dev_server
|
||||
esbuild_target = frappe.local.conf.get("esbuild_target") or os.environ.get("ESBUILD_TARGET")
|
||||
|
||||
mode = "development" if development else "production"
|
||||
if production:
|
||||
mode = "production"
|
||||
|
|
@ -93,6 +95,7 @@ def build(
|
|||
skip_frappe=skip_frappe,
|
||||
save_metafiles=save_metafiles,
|
||||
using_cached=using_cached,
|
||||
esbuild_target=esbuild_target,
|
||||
)
|
||||
|
||||
if apps and isinstance(apps, str):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue