Browse Source

Syncing package readmes with docs

v6-dev
Eli Perelman 8 years ago
parent
commit
79c3df0485
  1. 1
      docs/presets/neutrino-preset-node/README.md
  2. 1
      docs/presets/neutrino-preset-web/README.md
  3. 22
      packages/neutrino-preset-airbnb-base/README.md
  4. 8
      packages/neutrino-preset-jest/README.md
  5. 6
      packages/neutrino-preset-karma/README.md
  6. 6
      packages/neutrino-preset-mocha/README.md
  7. 103
      packages/neutrino-preset-node/README.md
  8. 17
      packages/neutrino-preset-react/README.md
  9. 110
      packages/neutrino-preset-web/README.md

1
docs/presets/neutrino-preset-node/README.md

@ -224,7 +224,6 @@ The following is a list of plugins and their identifiers which can be overridden
`devDependencies` of your package.json.
- `copy`: Copies non-JS files from `src` to `build` when using `neutrino build`.
- `clean`: Clears the contents of `build` prior to creating a production bundle.
- `progress`: Displays a progress bar when using `neutrino build`.
### Simple customization

1
docs/presets/neutrino-preset-web/README.md

@ -192,7 +192,6 @@ The following is a list of plugins and their identifiers which can be overridden
- `hot`: Enables hot module reloading.
- `copy`: Copies non-JS files from `src` to `build` when using `neutrino build`.
- `clean`: Clears the contents of `build` prior to creating a production bundle.
- `progress`: Displays a progress bar when using `neutrino build`.
### Simple customization

22
packages/neutrino-preset-airbnb-base/README.md

@ -49,18 +49,18 @@ linting **before** your build preset. For example, if you are building your proj
```json
{
"scripts": {
"start": "neutrino start --presets neutrino-preset-airbnb-base neutrino-preset-web",
"build": "neutrino build --presets neutrino-preset-airbnb-base neutrino-preset-web"
"start": "neutrino start --use neutrino-preset-airbnb-base neutrino-preset-web",
"build": "neutrino build --use neutrino-preset-airbnb-base neutrino-preset-web"
}
}
```
Or if you have set up Neutrino with `neutrino.presets` in your package.json:
Or if you have set up Neutrino with `neutrino.use` in your package.json:
```json
{
"neutrino": {
"presets": [
"use": [
"neutrino-preset-airbnb-base",
"neutrino-preset-web"
]
@ -190,7 +190,7 @@ Neutrino middleware, making it easy to compose and extend the configuration.
_Example: Turn off semicolons from being required as defined by the Airbnb rules._
```js
// If using as middleware, remove from presets and .use it from your override:
// If using as middleware, remove from middleware and .use it from your override:
const airbnb = require('neutrino-preset-airbnb-base');
module.exports = neutrino => {
@ -224,7 +224,7 @@ module.exports = neutrino => {
`neutrino-lint-airbnb-base` also provides a method for getting the ESLint configuration suitable for use in an eslintrc
file. Typically this is used for providing hints or fix solutions to the development environment, e.g. IDEs and text
editors. Doing this requires [creating an instance of the Neutrino API](https://neutrino.js.org/api) and providing the presets uses.
If you keep this information in `neutrino.presets` in package.json, this should be relatively straightforward. By
If you keep this information in `neutrino.use` in package.json, this should be relatively straightforward. By
providing all the presets used to Neutrino, you can ensure all the linting options used across all those preset will be
merged together for your development environment, without the need for copying, duplication, or loss of organization and
separation. This is inherited from `neutrino-middleware-eslint`.
@ -233,16 +233,18 @@ _Example: Create a .eslintrc.js file in the root of the project._
```js
// .eslintrc.js
const Neutrino = require('neutrino');
const { Neutrino } = require('neutrino');
const pkg = require('./package.json');
const api = new Neutrino();
const api = Neutrino();
// If the Airbnb preset is not included in pkg.neutrino.presets,
// If the Airbnb preset is not included in pkg.neutrino.use,
// use it manually:
api.use(require('neutrino-preset-airbnb-base'));
// Add the rest of the presets:
pkg.neutrino.presets.map(preset => api.use(preset));
pkg.neutrino.use
.map(require)
.map(api.use);
module.exports = api.eslintrc();
```

8
packages/neutrino-preset-jest/README.md

@ -87,17 +87,17 @@ let's pretend this is a Node.js project:
```json
{
"scripts": {
"test": "neutrino test --presets neutrino-preset-node neutrino-preset-jest"
"test": "neutrino test --use neutrino-preset-node neutrino-preset-jest"
}
}
```
Or if you have set up Neutrino with `neutrino.presets` in your package.json:
Or if you have set up Neutrino with `neutrino.use` in your package.json:
```json
{
"neutrino": {
"presets": [
"use": [
"neutrino-preset-node",
"neutrino-preset-jest"
]
@ -218,7 +218,7 @@ _Example: Turn off bailing on test failures._
### Advanced configuration
By following the [customization guide](https://neutrino.jg.org/customization/advanced) and knowing the rule, and loader IDs above,
By following the [customization guide](https://neutrino.js.org/customization/advanced) and knowing the rule, and loader IDs above,
you can override and augment testing by creating a JS module which overrides the config.
You can also modify Jest settings by overriding with any options Jest accepts. In a standalone Jest project this is

6
packages/neutrino-preset-karma/README.md

@ -68,17 +68,17 @@ let's pretend this is a React project:
```json
{
"scripts": {
"test": "neutrino test --presets neutrino-preset-node neutrino-preset-karma"
"test": "neutrino test --use neutrino-preset-node neutrino-preset-karma"
}
}
```
Or if you have set up Neutrino with `neutrino.presets` in your package.json:
Or if you have set up Neutrino with `neutrino.use` in your package.json:
```json
{
"neutrino": {
"presets": [
"use": [
"neutrino-preset-react",
"neutrino-preset-karma"
]

6
packages/neutrino-preset-mocha/README.md

@ -66,17 +66,17 @@ let's pretend this is a Node.js project:
```json
{
"scripts": {
"test": "neutrino test --presets neutrino-preset-node neutrino-preset-mocha"
"test": "neutrino test --use neutrino-preset-node neutrino-preset-mocha"
}
}
```
Or if you have set up Neutrino with `neutrino.presets` in your package.json:
Or if you have set up Neutrino with `neutrino.use` in your package.json:
```json
{
"neutrino": {
"presets": [
"use": [
"neutrino-preset-node",
"neutrino-preset-mocha"
]

103
packages/neutrino-preset-node/README.md

@ -86,8 +86,8 @@ Now edit your project's package.json to add commands for starting and building t
```json
{
"scripts": {
"start": "neutrino start --presets neutrino-preset-node",
"build": "neutrino build --presets neutrino-preset-node"
"start": "neutrino start --use neutrino-preset-node",
"build": "neutrino build --use neutrino-preset-node"
}
}
```
@ -224,13 +224,52 @@ The following is a list of plugins and their identifiers which can be overridden
`devDependencies` of your package.json.
- `copy`: Copies non-JS files from `src` to `build` when using `neutrino build`.
- `clean`: Clears the contents of `build` prior to creating a production bundle.
- `progress`: Displays a progress bar when using `neutrino build`.
### Simple customization
By following the [customization guide](https://neutrino.js.org/customization/simple) and knowing the rule, loader, and plugin IDs above,
you can override and augment the build directly from package.json.
#### Compile targets
This preset uses babel-preset-env to compile code targeting the Node.js v6.9+. To change
the Node.js target from package.json, specify an object at `neutrino.options.compile.targets` which contains a
[babel-preset-env-compatible](https://github.com/babel/babel-preset-env#targetsnode) Node.js target.
_Example: Replace the preset Node.js target with support for Node.js 4.2:_
```json
{
"neutrino": {
"options": {
"compile": {
"targets": {
"node": 4.2
}
}
}
}
}
```
_Example: Change support to current Node.js version:_
```json
{
"neutrino": {
"options": {
"compile": {
"targets": {
"node": "current"
}
}
}
}
}
```
#### Other customization examples
_Example: Allow importing modules with an `.mjs` extension._
```json
@ -252,6 +291,64 @@ _Example: Allow importing modules with an `.mjs` extension._
By following the [customization guide](https://neutrino.js.org/customization/advanced) and knowing the rule, loader, and plugin IDs above,
you can override and augment the build by creating a JS module which overrides the config.
#### Compile targets
This preset uses babel-preset-env to compile code targeting the Node.js v6.9+. To change
the Node.js target from package.json, specify an object at `neutrino.options.compile.targets` which contains a
[babel-preset-env-compatible](https://github.com/babel/babel-preset-env#targetsnode) Node.js target.
**Note: Setting these options via `neutrino.options.compile` must be done prior to loading the Node.js preset or they
will not be picked up by the compile middleware. These examples show changing compile targets with options before
loading the preset and overriding them if loaded afterwards.**
_Example: Replace the preset Node.js target with support for Node.js 4.2:_
```js
module.exports = neutrino => {
// Using neutrino.options prior to loading Node.js preset
neutrino.options.compile = {
targets: {
node: 4.2
}
};
// Using compile options override following loading Node.js preset
neutrino.config.module
.rule('compile')
.use('babel')
.tap(options => {
options.presets[0][1].targets.node = 4.2;
return options;
});
};
```
_Example: Change support to current Node.js version:_
```js
module.exports = neutrino => {
// Using neutrino.options prior to loading Node.js preset
neutrino.options.compile = {
targets: {
node: 4.2
}
};
// Using compile options override following loading Node.js preset
neutrino.config.module
.rule('compile')
.use('babel')
.tap(options => {
options.presets[0][1].targets.node = 'current';
return options;
});
};
```
#### Other customization examples
_Example: Allow importing modules with an `.mjs` extension._
```js

17
packages/neutrino-preset-react/README.md

@ -9,7 +9,7 @@
- Modern Babel compilation adding JSX and object rest spread syntax.
- Support for React Hot Loader
- Write JSX in .js or .jsx files
- Extends from [neutrino-preset-web](https://npmjs.org/package/neutrino-preset-web)
- Extends from [neutrino-preset-web](https://neutrino.js.org/presets/neutrino-preset-web)
- Modern Babel compilation supporting ES modules, last 2 major browser versions, async functions, and dynamic imports
- Webpack loaders for importing HTML, CSS, images, icons, and fonts
- Webpack Dev Server during development
@ -75,8 +75,8 @@ Now edit your project's package.json to add commands for starting and building t
```json
{
"scripts": {
"start": "neutrino start --presets neutrino-preset-react",
"build": "neutrino build --presets neutrino-preset-react"
"start": "neutrino start --use neutrino-preset-react",
"build": "neutrino build --use neutrino-preset-react"
}
}
```
@ -121,11 +121,18 @@ manifest.2211d9c1970bbd3c952b.bundle.js 1.41 kB 1 [emitted] manifest
You can either serve or deploy the contents of this `build` directory as a static site.
## Paths
The `neutrino-preset-web` preset loads assets relative to the path of your application by setting Webpack's
[`output.publicPath`](https://webpack.js.org/configuration/output/#output-publicpath) to `./`. If you wish to load
assets instead from a CDN, or if you wish to change to an absolute path for your application, customize your build to
override `output.publicPath`. See the [Customizing](#Customizing) section below.
## Customizing
To override the build configuration, start with the documentation on [customization](https://neutrino.js.org/customization).
`neutrino-preset-react` does not use any additional named rules, loaders, or plugins that aren't already in use by the
Web preset. See the [Web documentation customization](../neutrino-preset-web#customizing)
Web preset. See the [Web documentation customization](https://neutrino.js.org/presets/neutrino-preset-web#customizing)
for preset-specific configuration to override.
### Simple customization
@ -181,7 +188,7 @@ manifest.29ee4d0db8f2534cc643.bundle.js 1.44 kB 2 [emitted] manifest
#### HTML files
If you wish to override how HTML files are created for your React app, refer to the [relevant section on
neutrino-preset-web](https://neutrino.js.org/neutrino-preset-web#html-files).
neutrino-preset-web](https://neutrino.js.org/presets/neutrino-preset-web#html-files).
_Example: Change the application mount ID from "root" to "app":_

110
packages/neutrino-preset-web/README.md

@ -70,8 +70,8 @@ Now edit your project's package.json to add commands for starting and building t
```json
{
"scripts": {
"start": "neutrino start --presets neutrino-preset-web",
"build": "neutrino build --presets neutrino-preset-web"
"start": "neutrino start --use neutrino-preset-web",
"build": "neutrino build --use neutrino-preset-web"
}
}
```
@ -153,6 +153,13 @@ if (module.hot) {
Using dynamic imports with `import()` will automatically create split points and hot replace those modules upon
modification during development.
## Paths
By default this preset loads assets relative to the path of your application by setting Webpack's
[`output.publicPath`](https://webpack.js.org/configuration/output/#output-publicpath) to `./`. If you wish to load
assets instead from a CDN, or if you wish to change to an absolute path for your application, customize your build to
override `output.publicPath`. See the [Customizing](#Customizing) section below.
## Customizing
To override the build configuration, start with the documentation on [customization](https://neutrino.js.org/customization).
@ -185,13 +192,54 @@ The following is a list of plugins and their identifiers which can be overridden
- `hot`: Enables hot module reloading.
- `copy`: Copies non-JS files from `src` to `build` when using `neutrino build`.
- `clean`: Clears the contents of `build` prior to creating a production bundle.
- `progress`: Displays a progress bar when using `neutrino build`.
### Simple customization
By following the [customization guide](https://neutrino.js.org/customization/simple) and knowing the rule, loader, and plugin IDs above,
you can override and augment the build directly from package.json.
#### Compile targets
This preset uses babel-preset-env to compile code targeting the last 2 browser versions of major browsers. To change
the browser targets from package.json, specify an object at `neutrino.options.compile.targets` which contains a
[browserlist-compatible](https://github.com/ai/browserslist) array of browser targets.
_Example: Replace the Web preset browser targets with support for browsers with greater than 5% global usage:_
```json
{
"neutrino": {
"options": {
"compile": {
"targets": {
"browsers": [
"> 5%"
]
}
}
}
}
}
```
_Example: Change support to latest version instead of last 2 versions:_
```json
{
"neutrino": {
"options": {
"compile": {
"targets": {
"browsers": [
"last 1 version"
]
}
}
}
}
}
```
#### Vendoring
By defining an entry point in package.json named `vendor` you can split out external dependencies into a chunk separate
@ -241,6 +289,62 @@ _Example: Change the application mount ID from "root" to "app":_
By following the [customization guide](https://neutrino.js.org/customization/advanced) and knowing the rule, loader, and plugin IDs above,
you can override and augment the build by creating a JS module which overrides the config.
#### Compile targets
This preset uses babel-preset-env to compile code targeting the last 2 browser versions of major browsers. To change
the browser targets from an override file, specify an object at `neutrino.options.compile.targets` which contains a
[browserlist-compatible](https://github.com/ai/browserslist) array of browser targets.
**Note: Setting these options via `neutrino.options.compile` must be done prior to loading the Web preset or they
will not be picked up by the compile middleware. These examples show changing compile targets with options before
loading the preset and overriding them if loaded afterwards.**
_Example: Replace the Web preset browser targets with support for browsers with greater than 5% global usage:_
```js
module.exports = neutrino => {
// Using neutrino.options prior to loading Web preset
neutrino.options.compile = {
targets: {
browsers: ['> 5%']
}
};
// Using compile options override following loading Web preset
neutrino.config.module
.rule('compile')
.use('babel')
.tap(options => {
options.presets[0][1].targets.browsers = ['> 5%'];
return options;
});
};
```
_Example: Change support to latest version instead of last 2 versions:_
```js
module.exports = neutrino => {
// Using neutrino.options prior to loading Web preset
neutrino.options.compile = {
targets: {
browsers: ['last 1 version']
}
};
// Using compile options override following loading Web preset
neutrino.config.module
.rule('compile')
.use('babel')
.tap(options => {
options.presets[0][1].targets.browsers = ['last 1 version'];
return options;
});
};
```
#### Vendoring
By defining an entry point named `vendor` you can split out external dependencies into a chunk separate

Loading…
Cancel
Save