Skip to content

Commit

Permalink
Fix api docs loadconfigfile (#3757)
Browse files Browse the repository at this point in the history
* fix api docs for loadConfigFile

* fix linting

* fix to use optionsObj not options

* fix text to say objects not object
  • Loading branch information
maxwell8888 committed Sep 3, 2020
1 parent 266fd88 commit 581c1fc
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions docs/02-javascript-api.md
Expand Up @@ -213,23 +213,26 @@ const rollup = require('rollup');
// load the config file next to the current script;
// the provided config object has the same effect as passing "--format es"
// on the command line and will override the format of all outputs
loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { format: 'es' })
.then(async ({options, warnings}) => {
// "warnings" wraps the default `onwarn` handler passed by the CLI.
// This prints all warnings up to this point:
console.log(`We currently have ${warnings.count} warnings`);

// This prints all deferred warnings
warnings.flush();

// options is an "inputOptions" object with an additional "output"
// property that contains an array of "outputOptions".
// The following will generate all outputs and write them to disk the same
// way the CLI does it:
const bundle = await rollup.rollup(options);
await Promise.all(options.output.map(bundle.write));

// You can also pass this directly to "rollup.watch"
rollup.watch(options);
})
```
loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { format: 'es' }).then(
async ({ options, warnings }) => {
// "warnings" wraps the default `onwarn` handler passed by the CLI.
// This prints all warnings up to this point:
console.log(`We currently have ${warnings.count} warnings`);

// This prints all deferred warnings
warnings.flush();

// options is an array of "inputOptions" objects with an additional "output"
// property that contains an array of "outputOptions".
// The following will generate all outputs for all inputs, and write them to disk the same
// way the CLI does it:
for (const optionsObj of options) {
const bundle = await rollup.rollup(optionsObj);
await Promise.all(optionsObj.output.map(bundle.write));
}

// You can also pass this directly to "rollup.watch"
rollup.watch(options);
}
);
```

0 comments on commit 581c1fc

Please sign in to comment.