Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,31 @@ Nollup provides a dev server which can be used as a CLI command.

See "Nollup Options" for list of available flags.

## .nolluprc
## Configuration

Configuration file that can be used to pass configuration instead of as flags through the CLI.

```
You can use a configuration file as alternative to CLI flags or to complement them.

Configuration files are read using [cosmiconfig](https://github.com/davidtheclark/cosmiconfig).

This means configuration will be looked for in the following places in the order listed:

1. A `nollup` property in a `package.json` file.
2. A `.nolluprc` file with `JSON` or `YAML` syntax.
3. A `.nolluprc.json` file.
4. A `.nolluprc.yaml`, `.nolluprc.yml`, or `.nolluprc.js` file.
5. A `nollup.config.js` JS file exporting the object.

`.nolluprc`
```json
{
"hot": true,
"contentBase": "./public"
}
```

A JavaScript file called ```.nolluprc.js``` can be used instead.

```
`.nolluprc.js`
```javascript
module.exports = {
hot: true,
contentBase: './public'
Expand Down
9 changes: 5 additions & 4 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let path = require('path');
let express = require('express');
let fallback = require('express-history-api-fallback');
let proxy = require('express-http-proxy');
let cosmiconfig = require('cosmiconfig');
let nollupDevServer = require('./dev-middleware');
let ConfigLoader = require('./impl/ConfigLoader');
let app = express();
Expand Down Expand Up @@ -90,10 +91,10 @@ for (let i = 0; i < process.argv.length; i++) {
}

(async function () {
if (fs.existsSync('.nolluprc')) {
options = Object.assign({}, options, JSON.parse(fs.readFileSync('.nolluprc')));
} else if (fs.existsSync('.nolluprc.js')) {
options = Object.assign({}, options, require(path.resolve(process.cwd(), './.nolluprc.js')));
const cosmiconfigResult = cosmiconfig.cosmiconfigSync('nollup').search()

if (cosmiconfigResult && cosmiconfigResult.config) {
options = Object.assign({}, options, cosmiconfigResult.config);
}

if (options.before) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"acorn": "^7.0.0",
"chokidar": "^2.0.2",
"convert-source-map": "^1.5.1",
"cosmiconfig": "^6.0.0",
"express": "^4.16.3",
"express-history-api-fallback": "^2.2.1",
"express-http-proxy": "^1.5.1",
Expand Down