Comments (3)
The define
option can only replace JSON literals and a few a.b
like variables. However, you can use the inject option to provide variables in a more expressive way. For example:
// create a file named shims.js
export const __WS_URL__ = 'wss://'+document.domain+'/wss'
// then inject it
esbuild.build({
...options,
inject: ['./shims.js']
})
from esbuild.
I'm closing this issue because esbuild is working as intended here. I agree that inject is likely the best fit for your use case. The difference is that define
inlines compile-time constants while inject
references (but does not inline) variables from arbitrary code. They are used for different purposes.
from esbuild.
I got it.Thanks for your answer @evanw @hyrious
from esbuild.
Related Issues (20)
- 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
- [Documentation] Document the failure mode for unsupported node-specific features in dependencies HOT 1
- serve proxy with http2 possible? HOT 1
- A crash happened between switches of branches HOT 1
- Random "all goroutines are asleep - deadlock!" on a build HOT 2
- "all goroutines are asleep - deadlock!" on a build HOT 7
- esbuild + ESM + NodeJS + Typescript troubles HOT 6
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.