I have two separate questions,
1. How to build two files using esbuild?
in the config/config.exs
file, here is the default esbuild configuration:
config :esbuild,
version: "0.14.29",
default: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
it only produces one file which is js/app.js
, how can I generate two files using two separate input files?
2. What is the best way to use different js code in different pages?
let’s say that page 1 needs script 1 only
but page 2 needs script 1 AND script 2
is it better to make two separate js files and serve them when needed or just combine every thing in one file and send it to the user (regardless of whether he will visit the pages that need the other script or not)