|
|
@ -54,9 +54,135 @@ your project._ |
|
|
|
} |
|
|
|
``` |
|
|
|
|
|
|
|
Other than actually changing the config, that is all the setup necessary for Neutrino to pick up your custom changes. |
|
|
|
Other than actually changing the build configuration or Neutrino options, that is all the setup necessary for Neutrino |
|
|
|
to pick up your custom changes. |
|
|
|
|
|
|
|
## Configuring |
|
|
|
## Overriding Neutrino options |
|
|
|
|
|
|
|
Neutrino has a number of useful options for customizing its behavior, as well as the behavior of presets and middleware. |
|
|
|
You can override these options using an object at `neutrino.options`. |
|
|
|
|
|
|
|
**Important! Some of these options are used by presets and middleware to determine their path locations for building. |
|
|
|
Making changes to these in advanced configuration will usually mean needing to set Neutrino options before other presets |
|
|
|
are loaded, and overriding build configuration after the presets have loaded. Consider using |
|
|
|
[simple customization](./simple.md) for setting Neutrino options and preset/middleware-specific options.** |
|
|
|
|
|
|
|
### `options.root` |
|
|
|
|
|
|
|
Set the base directory which Neutrino middleware and presets operate on. Typically this is the project directory where |
|
|
|
the package.json would be located. If the option is not set, Neutrino defaults it to `process.cwd()`. If a relative |
|
|
|
path is specified, it will be resolved relative to `process.cwd()`; absolute paths will be used as-is. |
|
|
|
|
|
|
|
```js |
|
|
|
module.exports = neutrino => { |
|
|
|
// if not specified, defaults to process.cwd() |
|
|
|
neutrino.options.root; |
|
|
|
|
|
|
|
// relative, resolves to process.cwd() + ./website |
|
|
|
neutrino.options.root = './website'; |
|
|
|
|
|
|
|
// absolute |
|
|
|
neutrino.options.root = '/code/website'; |
|
|
|
}; |
|
|
|
``` |
|
|
|
|
|
|
|
### `options.source` |
|
|
|
|
|
|
|
Set the directory which contains the application source code. If the option is not set, Neutrino defaults it to `src`. |
|
|
|
If a relative path is specified, it will be resolved relative to `options.root`; absolute paths will be used as-is. |
|
|
|
|
|
|
|
```js |
|
|
|
module.exports = neutrino => { |
|
|
|
// if not specified, defaults to options.root + src |
|
|
|
neutrino.options.source; |
|
|
|
|
|
|
|
// relative, resolves to options.root + ./lib |
|
|
|
neutrino.options.source = './lib'; |
|
|
|
|
|
|
|
// absolute |
|
|
|
neutrino.options.source = '/code/website/lib'; |
|
|
|
}; |
|
|
|
``` |
|
|
|
|
|
|
|
### `options.output` |
|
|
|
|
|
|
|
Set the directory which will be the output of built assets. If the option is not set, Neutrino defaults it to `build`. |
|
|
|
If a relative path is specified, it will be resolved relative to `options.root`; absolute paths will be used as-is. |
|
|
|
|
|
|
|
```js |
|
|
|
module.exports = neutrino => { |
|
|
|
// if not specified, defaults to options.root + build |
|
|
|
neutrino.options.output; |
|
|
|
|
|
|
|
// relative, resolves to options.root + ./dist |
|
|
|
neutrino.options.output = './dist'; |
|
|
|
|
|
|
|
// absolute |
|
|
|
neutrino.options.output = '/code/website/dist'; |
|
|
|
}; |
|
|
|
``` |
|
|
|
|
|
|
|
### `options.tests` |
|
|
|
|
|
|
|
Set the directory that contains test files. If the option is not set, Neutrino defaults it to `test`. |
|
|
|
If a relative path is specified, it will be resolved relative to `options.root`; absolute paths will be used as-is. |
|
|
|
|
|
|
|
```js |
|
|
|
module.exports = neutrino => { |
|
|
|
// if not specified, defaults to options.root + test |
|
|
|
neutrino.options.tests; |
|
|
|
|
|
|
|
// relative, resolves to options.root + ./testing |
|
|
|
neutrino.options.tests = './testing'; |
|
|
|
|
|
|
|
// absolute |
|
|
|
neutrino.options.tests = '/code/website/testing'; |
|
|
|
}; |
|
|
|
``` |
|
|
|
|
|
|
|
### `options.entry` |
|
|
|
|
|
|
|
Set the main entry point for the application. If the option is not set, Neutrino defaults it to `index.js`. |
|
|
|
If a relative path is specified, it will be resolved relative to `options.source`; absolute paths will be used as-is. |
|
|
|
|
|
|
|
```js |
|
|
|
module.exports = neutrino => { |
|
|
|
// if not specified, defaults to options.source + index.js |
|
|
|
neutrino.options.entry; |
|
|
|
|
|
|
|
// relative, resolves to options.source + ./entry.js |
|
|
|
neutrino.options.entry = './entry.js'; |
|
|
|
|
|
|
|
// absolute |
|
|
|
neutrino.options.entry = '/code/website/lib/entry.js'; |
|
|
|
}; |
|
|
|
``` |
|
|
|
|
|
|
|
### `options.node_modules` |
|
|
|
|
|
|
|
Set the directory which contains the Node.js modules of the project. If the option is not set, Neutrino defaults it to |
|
|
|
`node_modules`. If a relative path is specified, it will be resolved relative to `options.root`; absolute paths will be |
|
|
|
used as-is. |
|
|
|
|
|
|
|
```js |
|
|
|
module.exports = neutrino => { |
|
|
|
// if not specified, defaults to options.root + node_modules |
|
|
|
neutrino.options.node_modules; |
|
|
|
|
|
|
|
// relative, resolves to options.root + ./modules |
|
|
|
neutrino.options.node_modules = './modules'; |
|
|
|
|
|
|
|
// absolute |
|
|
|
neutrino.options.node_modules = '/code/website/modules'; |
|
|
|
}; |
|
|
|
``` |
|
|
|
|
|
|
|
### Middleware or preset options |
|
|
|
|
|
|
|
Some middleware and presets also have their own custom options. Consult the documentation for the package for specific |
|
|
|
details on its customization. |
|
|
|
|
|
|
|
## Overriding build configuration |
|
|
|
|
|
|
|
The Neutrino instance provided to your custom configurator has a `config` property that is an instance of |
|
|
|
[webpack-chain](https://github.com/mozilla-neutrino/webpack-chain). We won't go in-depth of all the configuration |
|
|
|