Separate builds for production and development/test #32
Replies: 5 comments 3 replies
-
my temporary solution:
#!/usr/bin/env node
require('dotenv').config()
const { exec } = require("child_process")
const logAndExec = (command) => {
command = `${command} ${process.argv[2]}`
console.log(command)
exec(command)
}
if (process.env.NODE_ENV === "production") {
logAndExec("esbuild app/javascript/*.* --bundle --outdir=app/assets/builds '--define:process.env.NODE_ENV=\"production\"' --minify")
} else {
logAndExec("esbuild app/javascript/*.* --bundle --outdir=app/assets/builds")
} and in
|
Beta Was this translation helpful? Give feedback.
-
I think that's a fine solution. But I don't think it's something we need/want to add as defaults here. These shims should be just enough to get started and going, and then you can specialize from there. |
Beta Was this translation helpful? Give feedback.
-
ok a better script for reference: #!/usr/bin/env ruby
def log_and_exec(*args)
args += ARGV
puts args.join(" ")
system(args.join(" "))
end
if ENV["NODE_ENV"] == "production"
log_and_exec(
"esbuild",
"app/javascript/*.*",
"--bundle",
"--outdir=app/assets/builds",
"'--define:process.env.NODE_ENV=\"production\"'",
"--minify"
)
else
log_and_exec(
"esbuild",
"app/javascript/*.*",
"--bundle",
"--outdir=app/assets/builds",
)
end |
Beta Was this translation helpful? Give feedback.
-
I could see us adding something like this to a wiki here? |
Beta Was this translation helpful? Give feedback.
-
Is this solution too easy? package.json "scripts": {
"build": "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds --minify",
"build-dev": "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds"
} Procfile.dev
|
Beta Was this translation helpful? Give feedback.
-
e.g. I would like to have:
for production. (this is necessary to have the production build of react that is like 3-5x smaller)
And:
for development/test.
seems like there should be
yarn build:production
hooked intorake assets:prepare
instead ofyarn build
Beta Was this translation helpful? Give feedback.
All reactions