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)
- idea: bundle embed or static file inside a single file. HOT 3
- Source maps containing `https://` urls get mangled
- Please give me tips how to solve router plain javascript app HOT 2
- How to get final version of build.initialOptions inside a plugin? HOT 2
- Basic question: where is the code that interacts with Nodejs workers? HOT 2
- How to add success log to watch ? HOT 2
- Bundling with HTML HOT 3
- How to build for adobe jsx? HOT 2
- CSS transforms can break nested selectors HOT 3
- Feature Request: Allow absolute paths for resolved chunks HOT 3
- Dynamic import issue when using react hook useEffect inside a remote component HOT 4
- Track which entryfile changed
- Glob pattern for `copy` file loader HOT 2
- Forcing node_modules resolution with the `resolve` function HOT 2
- punycode should be 'external' but bundled ? HOT 2
- Control module bundle dividers HOT 2
- [ERROR] Unexpected end of file in JSON ../jsconfig.json:18:0 - File does not exist in project and node_modules HOT 1
- `OnLoad` in custom plugin is called for disabled modules
- Specifying where compiled CSS files stored
- Assigning to the variable `name` doesnโt work when bundling to ESM output HOT 2
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.