Comments (7)
@ivanjeremic Any argument in the command line is converted to a key-value pair. So it will look something like
{
"process.env.NODE_ENV": `"production"`
}
If you are struggling to set this up, use a starter-template instead.
from esbuild.
Solved by wrapping production
in single quotes:
npx esbuild index.jsx --bundle --minify --outfile=out.min.js --define:process.env.NODE_ENV='production'
from esbuild.
When wrapping define in brackets as in the react example, the error is:
npx esbuild index.jsx --bundle --minify --outfile=out.min.js '--define:process.env.NODE_ENV="production"'
error: Use --outdir instead of --outfile when there are multiple entry points
And when not wrapping:
npx esbuild index.jsx --bundle --minify --outfile=out.min.js --define:process.env.NODE_ENV="production"
error: Invalid define: --define:process.env.NODE_ENV=production
OS: Windows x64
esbuild: [email protected]
from esbuild.
What shell is this? cmd.exe? WSL? Cygwin? Something else?
from esbuild.
I'm using cmder, it's using ConEmu under the hood.
package.json
also need to be updated:
"scripts": {
"build": "npm run build:prod",
"build:dev": "esbuild src/index.jsx --bundle --define:process.env.NODE_ENV='development' --outfile=bundle.js",
"build:prod": "esbuild src/index.jsx --bundle --define:process.env.NODE_ENV='production' --minify --outfile=bundle.min.js"
}
from esbuild.
How would this look like when using a JavaScript config file?
require("esbuild")
.build({
entryPoints: ["app.jsx"],
bundle: true,
inject: ["./react-shim.js"],
outfile: "out.js",
define: process.env.NODE_ENV = "production",
})
.catch(() => process.exit(1));
from esbuild.
@ivanjeremic Any argument in the command line is converted to a key-value pair. So it will look something like
{ "process.env.NODE_ENV": `"production"` }
If you are struggling to set this up, use a starter-template instead.
I try to setup esbuild for using a react component library, specifically there is one hook I want to make public on NPM and since rollup and webpack are not so my taste I wanted to learn esbuild and use it for that npm package(react hook), Can esbuild be used for this?
from esbuild.
Related Issues (20)
- Additional directories to watch HOT 3
- esbuild does not fail with undefined functions HOT 5
- Segmentation fault when using with vite and sveltekit project HOT 1
- Glob imports must match exactly
- Pass argument to IIFE HOT 2
- Esbuild causing bundle breakage when applied twice to the same bundle
- Splitting results in `Dynamic require of "<filename>" is not supported` when targeting `chrome62`
- [Feature Request] Add built-in HTML loader HOT 1
- Imports from stdio entrypoint don't have a namespace set
- DCE is not removed when value is from a const in another module.
- Get metafile info from a `watch()` rebuild HOT 2
- removes the backslash "\" when minify option is false HOT 8
- [Sourcemap] Private properties don't get sourcemapped correctly HOT 3
- ENV Secrets accessible from js code in a React + Rails APP. HOT 7
- [Feature] Ability to save charts from Bundle Size Analyzer as svg files
- TypeError: Cannot set property X of #<Object> which has only a getter HOT 2
- Line limit option (lineLimit) breaks code HOT 3
- `esnext` target doesn't transform using declarations but `es2022` does HOT 2
- Default exports not handled correctly when external=true and module is dynamically imported (node16)
- Is there a problem here? does this make sense? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esbuild.