-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support --environment in CLI #388
Conversation
👍🏻
|
support --environment in CLI
@Rich-Harris Is this only for CLI? If you want to do the same inside rollup.rollup{}, how you do it? I was re-thinking Rollup, and now with the new commits, I start to like it! Maybe it's should be a step-by-step intro page for nobs for me so people can get into this quickly? |
Yep, the assumption is that if you're using the JavaScript API you already have full control over the environment. So you can vary any of the options based on whatever conditions are relevant. Is there something specific you're unsure how to do?
Welcome back! #385 has some anecdotes from other people who struggled initially; it seems like some intro tutorials or screencasts would be a good idea. Hopefully we'll get round to that soon |
Issue for me is Mac vs Windows. If I use Rollup config file and want it to react on a variable environment, I have to use two build commands in the script section in the package.json. One for mac and one for windows.
I didn't found a workaround for this, or can I use Rollup CLI here, and call the config file with it? Yep! Would be awsome if you get some tutorials and screencasts. Would helped me and others a lot! |
@himalayafan I'd love if NPM would provide a first class way to set NODE_ENV and others cross-platform. FYI there is https://www.npmjs.com/package/cross-env |
You could certainly use the Rollup CLI here... {
"scripts": {
"build": "rollup -c --environment ENV:development"
}
} ...unless your build script has a lot of custom stuff (since {
"scripts": {
"build": "babel-node scripts/build-dist dev"
}
} ...and then inside var target = process.argv[2] === 'dev' ? 'development' : 'production';
/* rest of the build script */ |
|
That makes sense, running Rollup with Babel seems to be a common point of confusion. Until we have such a guide, I recommend having two // my-project/.babelrc
{
"presets": ["es2015"]
} ...and one that goes in the // my-project/src/.babelrc
{
"presets": ["es2015-rollup"]
} This way, the appropriate configuration will be applied at the appropriate time. |
Makes sence. I guess I always disabled the |
@thisconnect you have to be careful though – options passed in directly will be merged with the nearest |
@Rich-Harris good to know, thanks. |
Closes #376. Adds an
--environment
option to the CLI with the following syntax, modelled after the syntax for-g
:This results in the following conditions inside the
rollup.config.js
file: