Arete Code
8 years ago
160 changed files with 26948 additions and 10521 deletions
@ -0,0 +1,38 @@ |
|||
language: node_js |
|||
node_js: |
|||
- '6.9' |
|||
- '7.7' |
|||
cache: |
|||
yarn: true |
|||
directories: |
|||
- node_modules |
|||
- packages/neutrino/node_modules |
|||
- packages/neutrino-middleware-banner/node_modules |
|||
- packages/neutrino-middleware-chunk/node_modules |
|||
- packages/neutrino-middleware-clean/node_modules |
|||
- packages/neutrino-middleware-compile-loader/node_modules |
|||
- packages/neutrino-middleware-copy/node_modules |
|||
- packages/neutrino-middleware-env/node_modules |
|||
- packages/neutrino-middleware-eslint/node_modules |
|||
- packages/neutrino-middleware-font-loader/node_modules |
|||
- packages/neutrino-middleware-hot/node_modules |
|||
- packages/neutrino-middleware-html-loader/node_modules |
|||
- packages/neutrino-middleware-html-template/node_modules |
|||
- packages/neutrino-middleware-image-loader/node_modules |
|||
- packages/neutrino-middleware-loader-merge/node_modules |
|||
- packages/neutrino-middleware-minify/node_modules |
|||
- packages/neutrino-middleware-named-modules/node_modules |
|||
- packages/neutrino-middleware-progress/node_modules |
|||
- packages/neutrino-middleware-start-server/node_modules |
|||
- packages/neutrino-middleware-style-loader/node_modules |
|||
- packages/neutrino-preset-airbnb-base/node_modules |
|||
- packages/neutrino-preset-jest/node_modules |
|||
- packages/neutrino-preset-karma/node_modules |
|||
- packages/neutrino-preset-mocha/node_modules |
|||
- packages/neutrino-preset-node/node_modules |
|||
- packages/neutrino-preset-react/node_modules |
|||
- packages/neutrino-preset-web/node_modules |
|||
before_script: |
|||
- yarn bootstrap |
|||
script: |
|||
- yarn test |
@ -1,27 +1,30 @@ |
|||
# Summary |
|||
|
|||
* [Introduction](/README.md) |
|||
* [Installation](/installation.md) |
|||
* [Usage](/usage.md) |
|||
* [Project Layout](/project-layout.md) |
|||
* [FAQ](/FAQ.md) |
|||
* [Presets](/presets/README.md) |
|||
* [Web](/presets/neutrino-preset-web/README.md) |
|||
* [React](/presets/neutrino-preset-react/README.md) |
|||
* [Node.js](/presets/neutrino-preset-node/README.md) |
|||
* [Airbnb](/presets/neutrino-preset-airbnb-base/README.md) |
|||
* [Karma](/presets/neutrino-preset-karma/README.md) |
|||
* [Mocha](/presets/neutrino-preset-mocha/README.md) |
|||
* [Jest](/presets/neutrino-preset-jest/README.md) |
|||
* [Community presets](/presets/community-presets.md) |
|||
* [Customization](/customization/README.md) |
|||
* [Simple](/customization/simple.md) |
|||
* [Advanced](/customization/advanced.md) |
|||
* [Creating presets](/creating-presets.md) |
|||
* [Creating linting presets](/presets/neutrino-lint-base/README.md) |
|||
* [Learning Resources](/learning-resources.md) |
|||
* [API](/api/README.md) |
|||
* [CLI](/cli/README.md) |
|||
* [Contributing](/contributing/README.md) |
|||
* [Development Process](/contributing/development.md) |
|||
* [Code of Conduct](/contributing/code-of-conduct.md) |
|||
* [Introduction](./README.md) |
|||
* [Installation](./installation.md) |
|||
* [Usage](./usage.md) |
|||
* [Project Layout](./project-layout.md) |
|||
* [FAQ](./FAQ.md) |
|||
* [Middleware](./middleware/README.md) |
|||
* [Presets](./presets/README.md) |
|||
* [Web](./presets/neutrino-preset-web/README.md) |
|||
* [React](./presets/neutrino-preset-react/README.md) |
|||
* [Node.js](./presets/neutrino-preset-node/README.md) |
|||
* [Airbnb](./presets/neutrino-preset-airbnb-base/README.md) |
|||
* [Karma](./presets/neutrino-preset-karma/README.md) |
|||
* [Mocha](./presets/neutrino-preset-mocha/README.md) |
|||
* [Jest](./presets/neutrino-preset-jest/README.md) |
|||
* [Community presets](./presets/community-presets.md) |
|||
* [Customization](./customization/README.md) |
|||
* [Simple](./customization/simple.md) |
|||
* [Advanced](./customization/advanced.md) |
|||
* [Creating presets](./creating-presets.md) |
|||
* [Creating linting presets](./presets/neutrino-lint-base/README.md) |
|||
* [Learning Resources](./learning-resources.md) |
|||
* [API](./api/README.md) |
|||
* [CLI](./cli/README.md) |
|||
* [Upgrading from v4 to v5](./upgrading-neutrino.md) |
|||
* [v4 Documentation](https://github.com/mozilla-neutrino/neutrino-dev/tree/docs-v4/docs) |
|||
* [Contributing](./contributing/README.md) |
|||
* [Development Process](./contributing/development.md) |
|||
* [Code of Conduct](./contributing/code-of-conduct.md) |
|||
|
@ -0,0 +1,124 @@ |
|||
# Middleware |
|||
|
|||
The basic unit of interacting with Neutrino is middleware. In Neutrino, middleware are functions |
|||
that are provided a Neutrino instance for the intent of modifying configuration, listening for |
|||
events, getting build metadata, or augmenting with custom functionality. At its simplest, a middleware |
|||
function accepts a Neutrino instance argument and does nothing: |
|||
|
|||
```js |
|||
function middleware(neutrino) {} |
|||
``` |
|||
|
|||
A middleware function can also optionally accept an `options` argument which will be fed back into |
|||
the middleware function when used. |
|||
|
|||
```js |
|||
function middleware(neutrino, options) {} |
|||
``` |
|||
|
|||
The signature of this function is what we call "Neutrino middleware". If you're familiar with middleware from the |
|||
Express/connect world, this works similarly. When using Express middleware, you provide a function to Express which |
|||
receives arguments to modify a request or response along its lifecycle. There can be a number of middleware functions |
|||
that Express can load, each one potentially modifying a request or response in succession. |
|||
|
|||
Neutrino will execute middleware similarly, where each middleware function successively interacts with Neutrino along |
|||
the lifecycle. This is done by plugging in the middleware to Neutrino via the `use()` method. |
|||
|
|||
```js |
|||
const api = new Neutrino(); |
|||
|
|||
api.use(middleware); |
|||
api.use(middleware, options); |
|||
``` |
|||
|
|||
To use a concrete example, let's create middleware that adds an environment plugin: |
|||
|
|||
```js |
|||
const Neutrino = require('neutrino'); |
|||
const { EnvironmentPlugin } = require('webpack'); |
|||
|
|||
const api = new Neutrino(); |
|||
|
|||
function env(neutrino, additionalVars = []) { |
|||
neutrino.config |
|||
.plugin('env') |
|||
.use(EnvironmentPlugin, ['NODE_ENV', ...additionalVars]); |
|||
} |
|||
|
|||
api.use(env); // or: |
|||
api.use(env, ['SECRET_KEY']); |
|||
``` |
|||
|
|||
## Loading middleware |
|||
|
|||
Additional middleware can also be loaded from a middleware function. This makes their composition simpler for |
|||
consumers. |
|||
|
|||
```js |
|||
// neutrino-middleware-env |
|||
const { EnvironmentPlugin } = require('webpack'); |
|||
|
|||
module.exports = (neutrino, additionalVars = []) => neutrino.config |
|||
.plugin('env') |
|||
.use(EnvironmentPlugin, ['NODE_ENV', ...additionalVars]); |
|||
``` |
|||
|
|||
```js |
|||
// react preset (which is also middleware) |
|||
const env = require('./neutrino-middleware-env'); |
|||
|
|||
module.exports = neutrino => { |
|||
neutrino.use(env, ['SECRET_KEY']); |
|||
neutrino.use(/* next middleware */); |
|||
neutrino.use(/* next middleware */) |
|||
}; |
|||
``` |
|||
|
|||
## Configuring |
|||
|
|||
If your middleware requires configuration _outside_ of the options necessary for _running_ the middleware, |
|||
use a closure technique for simplifying this for your middleware consumers. In short, your module will provide a |
|||
function to consumers which, when executed, will return a Neutrino middleware function. Describing this in code: |
|||
|
|||
```js |
|||
module.exports = function wrapper(...args) { |
|||
return function middleware(neutrino, options) { |
|||
// do something with neutrino, options, and args |
|||
}; |
|||
}; |
|||
``` |
|||
|
|||
Let's create a contrived example using our `env` middleware. Let's use a closure to let the consumer provide an |
|||
alternate plugin name when creating the middleware: |
|||
|
|||
```js |
|||
// neutrino-middleware-env |
|||
const { EnvironmentPlugin } = require('webpack'); |
|||
|
|||
module.exports = (pluginName = 'env') => (neutrino, additionalVars = []) => { |
|||
neutrino.config |
|||
.plugin(pluginName) |
|||
.use(EnvironmentPlugin, ['NODE_ENV', ...additionalVars]); |
|||
}; |
|||
``` |
|||
|
|||
```js |
|||
// react preset (which is also middleware) |
|||
const env = require('./neutrino-middleware-env'); |
|||
|
|||
module.exports = neutrino => { |
|||
neutrino.use(env('ENV-PLUGIN'), ['SECRET_KEY']); |
|||
}; |
|||
``` |
|||
|
|||
## Distributing |
|||
|
|||
If you would like your middleware to be used by others, feel free to publish and distribute! By putting your middleware |
|||
on npm, GitHub, or another location, you can share the hard work put into abstracting away Neutrino and Webpack |
|||
interactions and save everyone in the community time and effort. As long as the Neutrino CLI, other middleware, or |
|||
presets can require your middleware, it puts no restrictions on where you want to host it. |
|||
|
|||
## Core middleware |
|||
|
|||
Neutrino maintains a number of core middleware packages which aid in creating the various preset packages we also |
|||
distribute. Continue onward for documentation on these various middleware packages. |
@ -0,0 +1,71 @@ |
|||
# Neutrino Banner Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-banner` is Neutrino middleware for injecting string content into source code files. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-banner` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-banner |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-banner |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-banner` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const banner = require('neutrino-middleware-banner'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(banner); |
|||
|
|||
// Also accepts options for Webpack's BannerPlugin |
|||
// https://webpack.js.org/plugins/banner-plugin/ |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(banner, { |
|||
banner: `require('source-map-support').install();`, |
|||
raw: true, |
|||
entryOnly: true |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-banner` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `banner`: Injects string content into application source code. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-banner.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-banner.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-banner |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,71 @@ |
|||
# Neutrino Chunk Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-chunk` is Neutrino middleware for optimizing Webpack bundles via `CommonsChunkPlugin`. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-chunk` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-chunk |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-chunk |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-chunk` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const chunk = require('neutrino-middleware-chunk'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(chunk); |
|||
|
|||
// Also accepts options for Webpack's CommonsChunkPlugin |
|||
// https://webpack.js.org/plugins/commons-chunk-plugin/ |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(chunk, { |
|||
minChunks: Infinity, |
|||
names: ['vendor', 'manifest'] |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-chunk` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `chunk`: Creates a separate file (known as a chunk), consisting of common modules shared between multiple entry |
|||
points. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-chunk.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-chunk.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-chunk |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,67 @@ |
|||
# Neutrino Clean Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-clean` is Neutrino middleware for removing directories before building. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-clean` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-clean |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-clean |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-clean` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const clean = require('neutrino-middleware-clean'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(clean); |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(clean, { |
|||
paths: [], |
|||
root: neutrino.options.root |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-clean` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `clean`: Removes directories before building. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-clean.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-clean.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-clean |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,69 @@ |
|||
# Neutrino Compile Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-compile-loader` is Neutrino middleware for compiling source code with Babel. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-compile-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-compile-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-compile-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-compile-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const compile = require('neutrino-middleware-compile-loader'); |
|||
|
|||
neutrino.use(compile, { |
|||
include: [], |
|||
exclude: [], |
|||
babel: {} |
|||
}); |
|||
``` |
|||
|
|||
- `include` should be an array of paths to include in the compilation. Maps to Webpack's |
|||
[`Rule.include`](https://webpack.js.org/configuration/module/#rule-include) |
|||
- `babel` is a [Babel configuration object](https://babeljs.io/docs/usage/api/#options), consumed by babel-loader. Use |
|||
this to set properties such as `presets`, `plugins`, and `env`. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-compile-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `compile`: Compiles JS and JSX files from the `src` directory using Babel. Contains a single loader named `babel`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-compile-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-compile-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-compile-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,73 @@ |
|||
# Neutrino Copy Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-copy` is Neutrino middleware for copying files during building. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-copy` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-copy |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-copy |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-copy` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const copy = require('neutrino-middleware-copy'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(copy); |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(copy, { |
|||
patterns: [], |
|||
options: {} |
|||
}); |
|||
``` |
|||
|
|||
The `patterns` and `options` are defined from the [CopyWebpackPlugin](https://github.com/kevlened/copy-webpack-plugin). |
|||
See their docs for details on valid values to specify. |
|||
|
|||
- `patterns`: An array of patterns specifying copy operations. |
|||
- `options`: An object specifying copy options. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-copy` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `copy`: Copy files during building. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-copy.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-copy.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-copy |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,67 @@ |
|||
# Neutrino Environment Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-env` is Neutrino middleware for injecting environment variable definitions into |
|||
source code at `process.env`. Always injects `process.env.NODE_ENV`, unless overridden. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-env` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-env |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-env |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-env` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const env = require('neutrino-middleware-env'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(env); |
|||
|
|||
// Usage with additional environment variables |
|||
neutrino.use(env, ['SECRET_KEY']); |
|||
``` |
|||
|
|||
This middleware optionally accepts an array of environment variables to additionally inject into source code. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-env` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `env`: Inject environment variables into source code at `process.env`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-env.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-env.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-env |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,138 @@ |
|||
# Neutrino ESLint Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-eslint` is Neutrino middleware for linting source code using ESLint and eslint-loader. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-eslint` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-eslint |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-eslint |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-eslint` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const eslint = require('neutrino-middleware-eslint'); |
|||
|
|||
// Usage shows default values |
|||
neutrino.use(eslint, { |
|||
test: /\.(js|jsx)$/, |
|||
include: [], /* Should specify either include or exclude */ |
|||
exclude: [], /* Should specify either include or exclude */ |
|||
eslint: { |
|||
failOnError: process.env.NODE_ENV !== 'development', |
|||
emitWarning: process.env.NODE_ENV !== 'development', |
|||
emitError: process.env.NODE_ENV !== 'development', |
|||
cwd: neutrino.options.root, |
|||
useEslintrc: false, |
|||
root: true, |
|||
plugins: ['babel'], |
|||
baseConfig: {}, |
|||
envs: ['es6'], |
|||
parser: 'babel-eslint', |
|||
parserOptions: { |
|||
ecmaVersion: 2017, |
|||
sourceType: 'module', |
|||
ecmaFeatures: { |
|||
objectLiteralDuplicateProperties: false, |
|||
generators: true, |
|||
impliedStrict: true |
|||
} |
|||
}, |
|||
settings: {}, |
|||
globals: ['process'], |
|||
rules: {} |
|||
} |
|||
}); |
|||
``` |
|||
|
|||
- `test`: Test which files should be linted. |
|||
- `include`: An array of paths to include in linting. Maps to Webpack's |
|||
[`Rule.include`](https://webpack.js.org/configuration/module/#rule-include) |
|||
- `exclude`: An array of paths to exclude from linting. Maps to Webpack's |
|||
[`Rule.exclude`](https://webpack.js.org/configuration/module/#rule-exclude) |
|||
- `eslint`: An ESLint CLIEngine configuration object for configuring ESLint. Use this to configure rules, |
|||
plugins, and other [ESLint options](http://eslint.org/docs/user-guide/configuring). |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-eslint` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `lint`: By default, lints JS and JSX files from included directories using ESLint. Contains a single loader named |
|||
`eslint`. |
|||
|
|||
## Information |
|||
|
|||
This middleware will show errors and warnings in the console during development, and will cause a failure when |
|||
creating a build bundle. |
|||
|
|||
--- |
|||
|
|||
If you want your preset or middleware to also extend from another **ESLint configuration or preset** that you have made |
|||
a dependency, you must use `baseConfig.extends` rather than just `extends`. This is a limitation of ESLint, not this |
|||
middleware. |
|||
|
|||
--- |
|||
|
|||
This middleware only configures a target environment for `es6`, leaving other build middleware free to add their own |
|||
target environments. If your middleware puts restrictions on which environments it is capable of running, please |
|||
document that clearly in your middleware. |
|||
|
|||
## eslintrc Config |
|||
|
|||
`neutrino-middleware-eslint` 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](../../api/README.md) and providing the presets uses. |
|||
If you keep this information in `neutrino.presets` 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 presets will be |
|||
merged together for your development environment, without the need for copying, duplication, or loss of organization and |
|||
separation. |
|||
|
|||
_Example: Create a .eslintrc.js file in the root of the project._ |
|||
|
|||
```js |
|||
// .eslintrc.js |
|||
const Neutrino = require('neutrino'); |
|||
const pkg = require('./package.json'); |
|||
const api = new Neutrino(); |
|||
|
|||
pkg.neutrino.presets.map(preset => neutrino.use(preset)); |
|||
|
|||
module.exports = api.eslintrc(); |
|||
``` |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-eslint.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-eslint.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-eslint |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,70 @@ |
|||
# Neutrino Font Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-font-loader` is Neutrino middleware for loading and importing font files from modules. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-font-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-font-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-font-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-font-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const fonts = require('neutrino-middleware-font-loader'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(fonts); |
|||
|
|||
// Usage showing default options |
|||
neutrino.use(fonts, { |
|||
limit: '10000' |
|||
}); |
|||
``` |
|||
|
|||
- `limit`: Return a Data URL if the file is smaller than a byte limit. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-font-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `woff`: Allows importing WOFF font files from modules. Contains a single loader named `url`. |
|||
- `ttf`: Allows importing TTF font files from modules. Contains a single loader named `url`. |
|||
- `eot`: Allows importing EOT font files from modules. Contains a single loader named `file`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-font-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-font-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-font-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,61 @@ |
|||
# Neutrino Hot Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-hot` is Neutrino middleware for enabled Hot Module Replacement with Webpack's |
|||
`HotModuleReplacementPlugin`. This middleware is usually only added during development. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-hot` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-hot |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-hot |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-hot` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const hot = require('neutrino-middleware-hot'); |
|||
|
|||
neutrino.use(hot); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-hot` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `hot`: Enables hot module replacement. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-hot.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-hot.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-hot |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,60 @@ |
|||
# Neutrino HTML Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-html-loader` is Neutrino middleware for loading and importing HTML files from modules. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-html-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-html-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-html-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-html-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const html = require('neutrino-middleware-html-loader'); |
|||
|
|||
neutrino.use(html); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-html-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `html`: Allows importing HTML files from modules. Contains a single loader named `file`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-html-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-html-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-html-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,75 @@ |
|||
# Neutrino HTML Template Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-html-template` is Neutrino middleware for automatically creating HTML files for configured |
|||
entry-points. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-html-template` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-html-template |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-html-template |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-html-template` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const template = require('neutrino-middleware-html-template'); |
|||
|
|||
// Usage shows default values |
|||
// Accepts options specified by HtmlWebpackTemplate |
|||
// https://github.com/jaketrent/html-webpack-template |
|||
neutrino.use(template, { |
|||
inject: false, |
|||
appMountId: 'root', |
|||
xhtml: true, |
|||
mobile: true, |
|||
minify: { |
|||
useShortDoctype: true, |
|||
keepClosingSlash: true, |
|||
collapseWhitespace: true, |
|||
preserveLineBreaks: true |
|||
} |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-html-template` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `html`: Automatically generates HTML files for configured entry-points. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-html-template.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-html-template.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-html-template |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,70 @@ |
|||
# Neutrino Image Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-image-loader` is Neutrino middleware for loading and importing image files from modules. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-image-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-image-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-image-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-image-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const images = require('neutrino-middleware-image-loader'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(images); |
|||
|
|||
// Usage showing default options |
|||
neutrino.use(images, { |
|||
limit: 8192 |
|||
}); |
|||
``` |
|||
|
|||
- `limit`: Return a Data URL if the file is smaller than a byte limit. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-image-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `img`: Allows importing JPEG, PNG, and GIF files from modules. Contains a single loader named `url`. |
|||
- `svg`: Allows importing SVG files from modules. Contains a single loader named `url`. |
|||
- `ico`: Allows importing ICO files from modules. Contains a single loader named `url`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-image-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-image-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-image-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,75 @@ |
|||
# Neutrino Loader Merge Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-loader-merge` is Neutrino middleware for easily performing a deep merge of options into |
|||
a named rule and named loader in a Neutrino configuration. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-loader-merge` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-loader-merge |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-loader-merge |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-loader-merge` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const loaderMerge = require('neutrino-middleware-loader-merge'); |
|||
|
|||
neutrino.use(loaderMerge('compile', 'babel'), { |
|||
plugins: ['object-rest-spread'] |
|||
}); |
|||
|
|||
// Equivalent to: |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.use('babel') |
|||
.tap(options => require('deepmerge')(options, { |
|||
plugins: ['object-rest-spread'] |
|||
})); |
|||
``` |
|||
|
|||
This middleware is a factory intended to be invoked with a rule name and a loader name for which to extend the options. |
|||
Upon invoking, it will return a middleware function to be provided to Neutrino's `use()` method. |
|||
|
|||
```js |
|||
const middleware = loaderMerge(ruleName, loaderName); |
|||
|
|||
neutrino.use(middleware, options); |
|||
``` |
|||
|
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-loader-merge` does not create any of its own conventions; it is only middleware |
|||
for extending the options for a rule loader which has create its own conventions. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-loader-merge.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-loader-merge.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-loader-merge |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,62 @@ |
|||
# Neutrino Minify Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-minify` is Neutrino middleware for minifying source code using |
|||
[`BabiliWebpackPlugin`](https://www.npmjs.com/package/babili-webpack-plugin). This middleware is usually only |
|||
added during production builds. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-minify` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-minify |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-minify |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-minify` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const minify = require('neutrino-middleware-minify'); |
|||
|
|||
neutrino.use(minify); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-minify` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `minify`: Minifies source code using `BabiliWebpackPlugin`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-minify.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-minify.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-minify |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,60 @@ |
|||
# Neutrino Named Modules Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-named-modules` is Neutrino middleware for enabling named modules output via `NamedModulesPlugin`. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-named-modules` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-named-modules |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-named-modules |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-named-modules` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const namedModules = require('neutrino-middleware-named-modules'); |
|||
|
|||
neutrino.use(namedModules); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-named-modules` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `named-modules`: Enables named modules for improved debugging and console output. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-named-modules.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-named-modules.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-named-modules |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,60 @@ |
|||
# Neutrino Progress Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-progress` is Neutrino middleware for displaying a progress bar showing the progress of a build. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-progress` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-progress |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-progress |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-progress` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const progress = require('neutrino-middleware-progress'); |
|||
|
|||
neutrino.use(progress); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-progress` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `progress`: Displays a bar showing progression of build. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-progress.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-progress.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-progress |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,69 @@ |
|||
# Neutrino Start Server Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-start-server` is Neutrino middleware for starting a Node.js server for a file upon |
|||
completion of a build. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-start-server` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-start-server |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-start-server |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-start-server` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const server = require('neutrino-middleware-start-server'); |
|||
|
|||
// Use with default options, starting the server |
|||
// for the main entry point, neutrino.options.entry |
|||
neutrino.use(server); |
|||
|
|||
// Usage with custom server file to start |
|||
neutrino.use(server, { name: 'custom.js' }); |
|||
``` |
|||
|
|||
By default this middleware will start a server with the single entry point configured in Neutrino. |
|||
This middleware optionally accepts an object with a `name` property for a path to a module which to start the server. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-start-server` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `start-server`: Start a Node.js for a configured entry point or specified file. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-start-server.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-start-server.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-start-server |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,61 @@ |
|||
# Neutrino Style Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-style-loader` is Neutrino middleware for loading and importing stylesheets from modules. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-style-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-style-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-style-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-style-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const styles = require('neutrino-middleware-style-loader'); |
|||
|
|||
neutrino.use(styles); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-style-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `css`: Allows importing CSS stylesheets from modules. Contains two loaders named `style` and `css` which use |
|||
`style-loader` and `css-loader`, respectively. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](../../contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-style-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-style-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-style-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -1,200 +0,0 @@ |
|||
# Neutrino Lint Base |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-lint-base` is an abstract Neutrino preset base that makes creating ESLint-based presets simpler. By creating |
|||
a linting preset that extends from `neutrino-lint-base`, the development overhead and dependencies needed can be |
|||
significantly reduced. Use it as a baseline to create your own linting presets easier and more quickly. |
|||
|
|||
## Features |
|||
|
|||
- Quickly and easily create your own Neutrino linting presets |
|||
- Modern Babel knowledge supporting ES modules, JSX (when used with React preset), Web and Node.js apps |
|||
- Highly visible during development, fails compilation when building for production |
|||
- Easily extensible to customize your project as needed |
|||
|
|||
## Development Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v4 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-lint-base` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-lint-base |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-lint-base |
|||
``` |
|||
|
|||
Your project should also install any dependencies needed to operate based on options passed to `eslint-loader` or |
|||
ESLint's CLIEngine. |
|||
|
|||
## Project Layout |
|||
|
|||
`neutrino-lint-base` follows the standard [project layout](/project-layout.md) specified by Neutrino. This |
|||
means that by default all project source code should live in a directory named `src` in the root of the |
|||
project. The `.js` or `.jsx` files in this directory are the ones that will be linted by your preset. |
|||
|
|||
## Creating the preset |
|||
|
|||
Your preset will follow the same guidelines for normally creating Neutrino presets, with your preset extending |
|||
`neutrino-lint-base`. This starts out by having your package module export a function which accepts a Neutrino instance: |
|||
|
|||
```js |
|||
module.exports = neutrino => { |
|||
// ... |
|||
}; |
|||
``` |
|||
|
|||
The next step is to `require`, or `import` if your package supports it, `neutrino-lint-base` and execute it with |
|||
Neutrino. This will add the lint base's configuration to Neutrino for your preset to extend further: |
|||
|
|||
```js |
|||
const lint = require('neutrino-lint-base'); |
|||
|
|||
module.exports = neutrino => { |
|||
lint(neutrino); |
|||
// ... |
|||
}; |
|||
``` |
|||
|
|||
Now comes the core of your own preset. By extending from `neutrino-lint-base`'s "lint" rule and "eslint" loader, you |
|||
can manipulate the options as you desire. Consider using a package such as |
|||
[`deepmerge`](https://www.npmjs.com/package/deepmerge) to make extending these options easier: |
|||
|
|||
_Example: Create a preset that shuts off semicolons from being required by ESLint._ |
|||
|
|||
```js |
|||
const lint = require('neutrino-lint-base'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = neutrino => { |
|||
lint(neutrino); |
|||
neutrino.config.module |
|||
.rule('lint') |
|||
.loader('eslint', props => merge(props, { |
|||
options: { |
|||
rules: { |
|||
semi: 'off' |
|||
} |
|||
} |
|||
})); |
|||
}; |
|||
``` |
|||
|
|||
_Example: Create a preset that lints a project using the Airbnb base ESLint rules._ |
|||
|
|||
```js |
|||
const lint = require('neutrino-lint-base'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = neutrino => { |
|||
lint(neutrino); |
|||
neutrino.config.module |
|||
.rule('lint') |
|||
.loader('eslint', props => merge(props, { |
|||
options: { |
|||
baseConfig: { |
|||
extends: ['airbnb-base'] |
|||
} |
|||
} |
|||
})); |
|||
}; |
|||
``` |
|||
|
|||
Visit the [creating presets](/creating-presets.md) documentation for more detailed information on creating your own |
|||
custom preset. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-lint-base` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `lint`: Lints JS and JSX files from the `src` directory using ESLint. Contains a single loader named `eslint`. |
|||
|
|||
## Information |
|||
|
|||
The lint base will show errors and warnings in the console during development, and will cause a failure when |
|||
creating a build bundle. |
|||
|
|||
--- |
|||
|
|||
If you want your preset to also extend from another ESLint configuration that you have made a dependency, you must use |
|||
`baseConfig.extends` rather than just `extends`. This is a limitation of ESLint, not this lint base. |
|||
|
|||
```js |
|||
const lint = require('neutrino-lint-base'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = neutrino => { |
|||
lint(neutrino); |
|||
neutrino.config.module |
|||
.rule('lint') |
|||
.loader('eslint', props => merge(props, { |
|||
options: { |
|||
baseConfig: { |
|||
extends: [ |
|||
'YOUR_ESLINT_CONFIGURATION_BASE_A', |
|||
'YOUR_ESLINT_CONFIGURATION_BASE_B' |
|||
] |
|||
} |
|||
} |
|||
})); |
|||
}; |
|||
``` |
|||
|
|||
--- |
|||
|
|||
The linting base only configures a target environment for `es6`, leaving other build presets free to add their own |
|||
target environments. If your preset puts restrictions on which environments it is capable of running, please document |
|||
that clearly in your preset. |
|||
|
|||
For specifics on what options are configured when using this linting base, please |
|||
[view the source](https://github.com/mozilla-neutrino/neutrino-dev/blob/master/packages/neutrino-lint-base/src/index.js). |
|||
|
|||
## eslintrc Config |
|||
|
|||
`neutrino-lint-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](/api/README.md) and providing the presets uses. If you |
|||
keep this information in `config.presets` 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. |
|||
|
|||
_Example: Create a .eslintrc.js file in the root of the project._ |
|||
|
|||
```js |
|||
// .eslintrc.js |
|||
const Neutrino = require('neutrino'); |
|||
const pkg = require('./package.json'); |
|||
const api = new Neutrino(pkg.config.presets); |
|||
|
|||
module.exports = api.custom.eslintrc(); |
|||
``` |
|||
|
|||
--- |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](/contributing/README.md) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-lint-base.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-lint-base.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-lint-base |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,213 @@ |
|||
# Upgrading from Neutrino v4 to v5 |
|||
|
|||
Neutrino v5 introduces a number of changes, with some of them being breaking changes. To upgrade from Neutrino v4 |
|||
to v5, be sure to check this list for tasks you may need to perform to use this latest version: |
|||
|
|||
- Updates to config for creating plugins (from webpack-chain v3 upgrade): |
|||
|
|||
```js |
|||
// Creating plugins in v4 |
|||
neutrino.config |
|||
.plugin(name) |
|||
.use(WebpackPlugin, ...args) |
|||
|
|||
// Creating plugins in v5 |
|||
neutrino.config |
|||
.plugin(name) |
|||
.use(WebpackPlugin, args) |
|||
``` |
|||
|
|||
- Updates to config for modifying plugins (from webpack-chain v3 upgrade): |
|||
|
|||
```js |
|||
// Modifying plugins in v4 |
|||
neutrino.config |
|||
.plugin(name) |
|||
.inject((Plugin, args) => new Plugin(...newArgs)) |
|||
|
|||
// Modifying plugins in v5 |
|||
neutrino.config |
|||
.plugin(name) |
|||
.tap(args => newArgs); |
|||
``` |
|||
|
|||
- Updates to config for creating loaders (from webpack-chain v3 upgrade): |
|||
|
|||
```js |
|||
// Creating loaders in v4 |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.loader('babel', 'babel-loader', { |
|||
options: { |
|||
plugins: ['object-rest-spread'] |
|||
} |
|||
}); |
|||
|
|||
// Creating loaders in v5 |
|||
neutrino.config |
|||
.rule('compile') |
|||
.use('babel') |
|||
.loader('babel-loader') |
|||
.options({ plugins: ['object-rest-spread'] }); |
|||
``` |
|||
|
|||
- Updates to config for modifying loaders (from webpack-chain v3 upgrade). The function now gets its options directly |
|||
instead of being nested in an object: |
|||
|
|||
```js |
|||
// Modifying loaders in v4 |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.loader('babel', props => merge(props, { |
|||
options: { |
|||
plugins: ['object-rest-spread'] |
|||
} |
|||
})); |
|||
|
|||
// Modifying loaders in v5 |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.use('babel') |
|||
.tap(options => merge(options, { plugins: ['object-rest-spread'] })); |
|||
``` |
|||
|
|||
- Updates to `include` and `exclude` for rules (from webpack-chain v3). In the previous webpack-chain |
|||
package, `include` and `exclude` were functions where you provided paths as arguments. These are now |
|||
`ChainedMap`s, making them much more extensible should you need to manipulate these values: |
|||
|
|||
```js |
|||
// Adding rule includes and excludes in v4 |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.include(x, y) |
|||
.exclude(x, y); |
|||
|
|||
// Adding rule includes and excludes in v5 |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.include |
|||
.add(x) |
|||
.add(y) |
|||
.end() |
|||
.exclude |
|||
.add(x) |
|||
.add(y); |
|||
|
|||
// You can also use .merge() to add multiple paths at once: |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.include.merge([x, y]).end() |
|||
.exclude.merge([x, y]); |
|||
``` |
|||
|
|||
- Simple configuration via package.json now done from top-level `neutrino` object. Rename `config` to `neutrino`, and |
|||
rename `config.neutrino` to `neutrino.config`. Presets also fall under this `neutrino` object. The `custom` object has |
|||
been renamed to `options`. |
|||
|
|||
```json |
|||
{ |
|||
"neutrino": { |
|||
"config": { |
|||
"entry": { |
|||
"vendor": ["react"] |
|||
} |
|||
}, |
|||
"presets": [ |
|||
"neutrino-preset-react" |
|||
], |
|||
"options": { |
|||
"mocha": { |
|||
"reporter": "nyan" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
- The Web preset has renamed its styling rule from `css` to `style`: |
|||
|
|||
```js |
|||
// v4 API for Web preset |
|||
neutrino.config.module.rule('css') |
|||
|
|||
// v5 API for Web preset |
|||
neutrino.config.module.rule('style') |
|||
``` |
|||
|
|||
```json |
|||
{ |
|||
"neutrino": { |
|||
"config": { |
|||
"module": { |
|||
"rule": { |
|||
"style": {} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
- Jest upgraded to v19, which changes the option `testPathDirs` to `roots`. Jest options set using |
|||
package.json can now only be done at `neutrino.options.jest` (no more package.json `jest`); |
|||
- Linting base is deprecated in favor of `neutrino-middleware-eslint`: |
|||
|
|||
```js |
|||
// v4 API |
|||
const lint = require('neutrino-lint-base'); |
|||
|
|||
lint(neutrino); |
|||
neutrino.config.module |
|||
.rule('lint') |
|||
.loader('eslint', props => merge(props, { rules: { /* */ } })); |
|||
|
|||
// v5 API |
|||
const eslint = require('neutrino-middleware-eslint'); |
|||
|
|||
neutrino.use(eslint, { |
|||
rules: { /* */ } |
|||
}) |
|||
``` |
|||
|
|||
- When using a linting preset or consuming anything with `neutrino-middleware-eslint`, the `eslintrc()` method has been |
|||
moved from `neutrino.custom.eslintrc` to `neutrino.eslintrc`: |
|||
|
|||
```js |
|||
// v4 API |
|||
neutrino.custom.eslintrc(); |
|||
|
|||
// v5 API |
|||
neutrino.eslintrc(); |
|||
``` |
|||
|
|||
- The Neutrino API no longer accepts preset strings in its constructor. The constructor now accepts an options object to |
|||
be set at `neutrino.options`: |
|||
|
|||
```js |
|||
const Neutrino = require('neutrino'); |
|||
const api = new Neutrino({ mocha: { reporter: 'nyan' } }); |
|||
|
|||
api.options.mocha.reporter // "nyan" |
|||
``` |
|||
|
|||
- Since the Neutrino API no longer accepts preset strings in its constructor, you must now pass presets and middleware |
|||
as code/functions to the `.use()` method. This means the API no longer does preset module resolution. This has been |
|||
moved to the CLI. |
|||
|
|||
```js |
|||
// v4 API |
|||
const Neutrino = require('neutrino'); |
|||
const api = new Neutrino(['neutrino-preset-node', 'neutrino-preset-mocha']); |
|||
|
|||
// v5 API |
|||
const Neutrino = require('neutrino'); |
|||
const api = new Neutrino(); |
|||
|
|||
api.use(require('neutrino-preset-node')); |
|||
api.use(require('neutrino.preset-mocha')); |
|||
``` |
|||
|
|||
- `neutrino.getWebpackOptions()` no longer caches the configuration after being called. |
|||
- Using a `node` target no longer skips the watcher for a builder, it now uses the Webpack source watcher. This means |
|||
commands like `neutrino start && node build` is obsolete. `neutrino build && node build` would work to start a Node |
|||
instance for production-built bundles. |
@ -1,17 +0,0 @@ |
|||
# Neutrino Lint Base |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-lint-base` is an abstract Neutrino preset base that makes creating ESLint-based presets simpler. By creating |
|||
a linting preset that extends from `neutrino-lint-base`, the development overhead and dependencies needed can be |
|||
significantly reduced. Use it as a baseline to create your own linting presets easier and more quickly. |
|||
|
|||
## Documentation |
|||
|
|||
See the [Neutrino docs](https://neutrino.js.org/presets/neutrino-lint-base/) |
|||
for details on installation, getting started, usage, and customizing. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-lint-base.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-lint-base.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-lint-base |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -1,27 +0,0 @@ |
|||
{ |
|||
"name": "neutrino-lint-base", |
|||
"version": "4.3.1", |
|||
"description": "Neutrino preset starter for adding building ESLint-based presets", |
|||
"main": "src/index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-preset", |
|||
"eslint" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "mozilla-neutrino/neutrino-dev", |
|||
"dependencies": { |
|||
"babel-eslint": "^7.1.1", |
|||
"eslint": "^3.16.1", |
|||
"eslint-loader": "^1.6.1", |
|||
"eslint-plugin-babel": "^4.0.1", |
|||
"eslint-plugin-import": "^2.2.0", |
|||
"lodash.clonedeep": "^4.5.0" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^4.0.0" |
|||
}, |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues" |
|||
} |
@ -1,55 +0,0 @@ |
|||
const clone = require('lodash.clonedeep'); |
|||
const path = require('path'); |
|||
|
|||
const MODULES = path.join(__dirname, '../node_modules'); |
|||
const IF_NOT_DEV = process.env.NODE_ENV !== 'development'; |
|||
|
|||
module.exports = neutrino => { |
|||
const { config } = neutrino; |
|||
|
|||
config |
|||
.module |
|||
.rule('lint') |
|||
.test(/\.(js|jsx)$/) |
|||
.pre() |
|||
.include(path.join(process.cwd(), 'src')) |
|||
.loader('eslint', require.resolve('eslint-loader'), { |
|||
failOnError: IF_NOT_DEV, |
|||
emitWarning: IF_NOT_DEV, |
|||
emitError: IF_NOT_DEV, |
|||
cwd: process.cwd(), |
|||
useEslintrc: false, |
|||
root: true, |
|||
plugins: ['babel'], |
|||
baseConfig: {}, |
|||
envs: ['es6'], |
|||
parser: 'babel-eslint', |
|||
parserOptions: { |
|||
ecmaVersion: 2017, |
|||
sourceType: 'module', |
|||
ecmaFeatures: { |
|||
objectLiteralDuplicateProperties: false, |
|||
generators: true, |
|||
impliedStrict: true |
|||
} |
|||
}, |
|||
settings: {}, |
|||
globals: ['process'], |
|||
rules: {} |
|||
}); |
|||
|
|||
config.resolve.modules.add(MODULES); |
|||
config.resolveLoader.modules.add(MODULES); |
|||
|
|||
neutrino.custom.eslintrc = () => { |
|||
const options = clone(config.module.rule('lint').loaders.get('eslint').options); |
|||
|
|||
options.extends = options.baseConfig.extends; |
|||
options.useEslintrc = true; |
|||
options.env = options.envs.reduce((env, key) => Object.assign(env, { [key]: true }), {}); |
|||
options.globals = options.globals.reduce((globals, key) => Object.assign(globals, { [key]: true }), {}); |
|||
['envs', 'baseConfig', 'failOnError', 'emitWarning', 'emitError'].map(method => delete options[method]); |
|||
|
|||
return options; |
|||
}; |
|||
}; |
@ -0,0 +1,71 @@ |
|||
# Neutrino Banner Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-banner` is Neutrino middleware for injecting string content into source code files. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-banner` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-banner |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-banner |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-banner` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const banner = require('neutrino-middleware-banner'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(banner); |
|||
|
|||
// Also accepts options for Webpack's BannerPlugin |
|||
// https://webpack.js.org/plugins/banner-plugin/ |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(banner, { |
|||
banner: `require('source-map-support').install();`, |
|||
raw: true, |
|||
entryOnly: true |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-banner` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `banner`: Injects string content into application source code. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-banner.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-banner.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-banner |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,12 @@ |
|||
const { BannerPlugin } = require('webpack'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => config |
|||
.plugin('banner') |
|||
.use(BannerPlugin, [ |
|||
merge({ |
|||
banner: `require('source-map-support').install();`, |
|||
raw: true, |
|||
entryOnly: true |
|||
}, options) |
|||
]); |
@ -0,0 +1,23 @@ |
|||
{ |
|||
"name": "neutrino-middleware-banner", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for injecting a banner into bundled files", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"banner" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-banner", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"deepmerge": "^1.3.2", |
|||
"webpack": "^2.2.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,71 @@ |
|||
# Neutrino Chunk Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-chunk` is Neutrino middleware for optimizing Webpack bundles via `CommonsChunkPlugin`. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-chunk` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-chunk |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-chunk |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-chunk` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const chunk = require('neutrino-middleware-chunk'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(chunk); |
|||
|
|||
// Also accepts options for Webpack's CommonsChunkPlugin |
|||
// https://webpack.js.org/plugins/commons-chunk-plugin/ |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(chunk, { |
|||
minChunks: Infinity, |
|||
names: ['vendor', 'manifest'] |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-chunk` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `chunk`: Creates a separate file (known as a chunk), consisting of common modules shared between multiple entry |
|||
points. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-chunk.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-chunk.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-chunk |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,8 @@ |
|||
const { CommonsChunkPlugin } = require('webpack').optimize; |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => config |
|||
.plugin('chunk') |
|||
.use(CommonsChunkPlugin, [ |
|||
merge({ minChunks: Infinity, names: ['vendor', 'manifest'] }, options) |
|||
]); |
@ -0,0 +1,23 @@ |
|||
{ |
|||
"name": "neutrino-middleware-chunk", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for chunking bundle assets", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"chunk" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-chunk", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"deepmerge": "^1.3.2", |
|||
"webpack": "^2.2.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,67 @@ |
|||
# Neutrino Clean Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-clean` is Neutrino middleware for removing directories before building. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-clean` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-clean |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-clean |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-clean` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const clean = require('neutrino-middleware-clean'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(clean); |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(clean, { |
|||
paths: [], |
|||
root: neutrino.options.root |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-clean` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `clean`: Removes directories before building. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-clean.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-clean.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-clean |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,10 @@ |
|||
const CleanPlugin = require('clean-webpack-plugin'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = (neutrino, options) => { |
|||
const { paths, root } = merge({ paths: [], root: neutrino.options.root }, options); |
|||
|
|||
neutrino.config |
|||
.plugin('clean') |
|||
.use(CleanPlugin, [paths, { root }]); |
|||
}; |
@ -0,0 +1,23 @@ |
|||
{ |
|||
"name": "neutrino-middleware-clean", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for cleaning bundle output directories", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"clean" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-clean", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"clean-webpack-plugin": "^0.1.15", |
|||
"deepmerge": "^1.3.2" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
|||
balanced-match@^0.4.1: |
|||
version "0.4.2" |
|||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" |
|||
|
|||
brace-expansion@^1.0.0: |
|||
version "1.1.6" |
|||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" |
|||
dependencies: |
|||
balanced-match "^0.4.1" |
|||
concat-map "0.0.1" |
|||
|
|||
clean-webpack-plugin@^0.1.15: |
|||
version "0.1.15" |
|||
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-0.1.15.tgz#facc04e0c8dba99bf451ae865ad0361f51af1df1" |
|||
dependencies: |
|||
rimraf "~2.5.1" |
|||
|
|||
concat-map@0.0.1: |
|||
version "0.0.1" |
|||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" |
|||
|
|||
deepmerge@^1.3.2: |
|||
version "1.3.2" |
|||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.3.2.tgz#1663691629d4dbfe364fa12a2a4f0aa86aa3a050" |
|||
|
|||
fs.realpath@^1.0.0: |
|||
version "1.0.0" |
|||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" |
|||
|
|||
glob@^7.0.5: |
|||
version "7.1.1" |
|||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" |
|||
dependencies: |
|||
fs.realpath "^1.0.0" |
|||
inflight "^1.0.4" |
|||
inherits "2" |
|||
minimatch "^3.0.2" |
|||
once "^1.3.0" |
|||
path-is-absolute "^1.0.0" |
|||
|
|||
inflight@^1.0.4: |
|||
version "1.0.6" |
|||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" |
|||
dependencies: |
|||
once "^1.3.0" |
|||
wrappy "1" |
|||
|
|||
inherits@2: |
|||
version "2.0.3" |
|||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" |
|||
|
|||
minimatch@^3.0.2: |
|||
version "3.0.3" |
|||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" |
|||
dependencies: |
|||
brace-expansion "^1.0.0" |
|||
|
|||
once@^1.3.0: |
|||
version "1.4.0" |
|||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" |
|||
dependencies: |
|||
wrappy "1" |
|||
|
|||
path-is-absolute@^1.0.0: |
|||
version "1.0.1" |
|||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" |
|||
|
|||
rimraf@~2.5.1: |
|||
version "2.5.4" |
|||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" |
|||
dependencies: |
|||
glob "^7.0.5" |
|||
|
|||
wrappy@1: |
|||
version "1.0.2" |
|||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" |
@ -0,0 +1,69 @@ |
|||
# Neutrino Compile Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-compile-loader` is Neutrino middleware for compiling source code with Babel. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-compile-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-compile-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-compile-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-compile-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const compile = require('neutrino-middleware-compile-loader'); |
|||
|
|||
neutrino.use(compile, { |
|||
include: [], |
|||
exclude: [], |
|||
babel: {} |
|||
}); |
|||
``` |
|||
|
|||
- `include` should be an array of paths to include in the compilation. Maps to Webpack's |
|||
[`Rule.include`](https://webpack.js.org/configuration/module/#rule-include) |
|||
- `babel` is a [Babel configuration object](https://babeljs.io/docs/usage/api/#options), consumed by babel-loader. Use |
|||
this to set properties such as `presets`, `plugins`, and `env`. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-compile-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `compile`: Compiles JS and JSX files from the `src` directory using Babel. Contains a single loader named `babel`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-compile-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-compile-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-compile-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,17 @@ |
|||
module.exports = ({ config }, options) => { |
|||
const rule = config.module |
|||
.rule('compile') |
|||
.test(options.test || /\.jsx?$/) |
|||
.use('babel') |
|||
.loader(require.resolve('babel-loader')) |
|||
.options(options.babel) |
|||
.end(); |
|||
|
|||
if (options.include) { |
|||
rule.include.merge(options.include); |
|||
} |
|||
|
|||
if (options.exclude) { |
|||
rule.exclude.merge(options.exclude); |
|||
} |
|||
}; |
@ -0,0 +1,27 @@ |
|||
{ |
|||
"name": "neutrino-middleware-compile-loader", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for compiling JavaScript using Babel configuration", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"compile", |
|||
"babel" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-compile-loader", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"babel-core": "^6.23.1", |
|||
"babel-loader": "^6.3.2" |
|||
}, |
|||
"devDependencies": { |
|||
"webpack": "^2.2.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,73 @@ |
|||
# Neutrino Copy Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-copy` is Neutrino middleware for copying files during building. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-copy` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-copy |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-copy |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-copy` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const copy = require('neutrino-middleware-copy'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(copy); |
|||
|
|||
// Usage shows the default values of this middleware: |
|||
neutrino.use(copy, { |
|||
patterns: [], |
|||
options: {} |
|||
}); |
|||
``` |
|||
|
|||
The `patterns` and `options` are defined from the [CopyWebpackPlugin](https://github.com/kevlened/copy-webpack-plugin). |
|||
See their docs for details on valid values to specify. |
|||
|
|||
- `patterns`: An array of patterns specifying copy operations. |
|||
- `options`: An object specifying copy options. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-copy` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `copy`: Copy files during building. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-copy.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-copy.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-copy |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,10 @@ |
|||
const CopyPlugin = require('copy-webpack-plugin'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, opts) => { |
|||
const { patterns, options } = merge({ patterns: [], options: {} }, opts); |
|||
|
|||
config |
|||
.plugin('copy') |
|||
.use(CopyPlugin, [patterns, options]); |
|||
}; |
@ -0,0 +1,24 @@ |
|||
{ |
|||
"name": "neutrino-middleware-copy", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for copying files to a bundle output directory", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"copy", |
|||
"copying" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-copy", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"copy-webpack-plugin": "^4.0.1", |
|||
"deepmerge": "^1.3.2" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
@ -0,0 +1,172 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
|||
balanced-match@^0.4.1: |
|||
version "0.4.2" |
|||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" |
|||
|
|||
big.js@^3.1.3: |
|||
version "3.1.3" |
|||
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" |
|||
|
|||
bluebird@^2.10.2: |
|||
version "2.11.0" |
|||
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" |
|||
|
|||
brace-expansion@^1.0.0: |
|||
version "1.1.6" |
|||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" |
|||
dependencies: |
|||
balanced-match "^0.4.1" |
|||
concat-map "0.0.1" |
|||
|
|||
concat-map@0.0.1: |
|||
version "0.0.1" |
|||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" |
|||
|
|||
copy-webpack-plugin@^4.0.1: |
|||
version "4.0.1" |
|||
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.0.1.tgz#9728e383b94316050d0c7463958f2b85c0aa8200" |
|||
dependencies: |
|||
bluebird "^2.10.2" |
|||
fs-extra "^0.26.4" |
|||
glob "^6.0.4" |
|||
is-glob "^3.1.0" |
|||
loader-utils "^0.2.15" |
|||
lodash "^4.3.0" |
|||
minimatch "^3.0.0" |
|||
node-dir "^0.1.10" |
|||
|
|||
deepmerge@^1.3.2: |
|||
version "1.3.2" |
|||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.3.2.tgz#1663691629d4dbfe364fa12a2a4f0aa86aa3a050" |
|||
|
|||
emojis-list@^2.0.0: |
|||
version "2.1.0" |
|||
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" |
|||
|
|||
fs-extra@^0.26.4: |
|||
version "0.26.7" |
|||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.7.tgz#9ae1fdd94897798edab76d0918cf42d0c3184fa9" |
|||
dependencies: |
|||
graceful-fs "^4.1.2" |
|||
jsonfile "^2.1.0" |
|||
klaw "^1.0.0" |
|||
path-is-absolute "^1.0.0" |
|||
rimraf "^2.2.8" |
|||
|
|||
fs.realpath@^1.0.0: |
|||
version "1.0.0" |
|||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" |
|||
|
|||
glob@^6.0.4: |
|||
version "6.0.4" |
|||
resolved "https://registry.yarnpkg.com/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22" |
|||
dependencies: |
|||
inflight "^1.0.4" |
|||
inherits "2" |
|||
minimatch "2 || 3" |
|||
once "^1.3.0" |
|||
path-is-absolute "^1.0.0" |
|||
|
|||
glob@^7.0.5: |
|||
version "7.1.1" |
|||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" |
|||
dependencies: |
|||
fs.realpath "^1.0.0" |
|||
inflight "^1.0.4" |
|||
inherits "2" |
|||
minimatch "^3.0.2" |
|||
once "^1.3.0" |
|||
path-is-absolute "^1.0.0" |
|||
|
|||
graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: |
|||
version "4.1.11" |
|||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" |
|||
|
|||
inflight@^1.0.4: |
|||
version "1.0.6" |
|||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" |
|||
dependencies: |
|||
once "^1.3.0" |
|||
wrappy "1" |
|||
|
|||
inherits@2: |
|||
version "2.0.3" |
|||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" |
|||
|
|||
is-extglob@^2.1.0: |
|||
version "2.1.1" |
|||
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" |
|||
|
|||
is-glob@^3.1.0: |
|||
version "3.1.0" |
|||
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" |
|||
dependencies: |
|||
is-extglob "^2.1.0" |
|||
|
|||
json5@^0.5.0: |
|||
version "0.5.1" |
|||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" |
|||
|
|||
jsonfile@^2.1.0: |
|||
version "2.4.0" |
|||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" |
|||
optionalDependencies: |
|||
graceful-fs "^4.1.6" |
|||
|
|||
klaw@^1.0.0: |
|||
version "1.3.1" |
|||
resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" |
|||
optionalDependencies: |
|||
graceful-fs "^4.1.9" |
|||
|
|||
loader-utils@^0.2.15: |
|||
version "0.2.17" |
|||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" |
|||
dependencies: |
|||
big.js "^3.1.3" |
|||
emojis-list "^2.0.0" |
|||
json5 "^0.5.0" |
|||
object-assign "^4.0.1" |
|||
|
|||
lodash@^4.3.0: |
|||
version "4.17.4" |
|||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" |
|||
|
|||
"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2: |
|||
version "3.0.3" |
|||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" |
|||
dependencies: |
|||
brace-expansion "^1.0.0" |
|||
|
|||
node-dir@^0.1.10: |
|||
version "0.1.16" |
|||
resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.16.tgz#d2ef583aa50b90d93db8cdd26fcea58353957fe4" |
|||
dependencies: |
|||
minimatch "^3.0.2" |
|||
|
|||
object-assign@^4.0.1: |
|||
version "4.1.1" |
|||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" |
|||
|
|||
once@^1.3.0: |
|||
version "1.4.0" |
|||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" |
|||
dependencies: |
|||
wrappy "1" |
|||
|
|||
path-is-absolute@^1.0.0: |
|||
version "1.0.1" |
|||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" |
|||
|
|||
rimraf@^2.2.8: |
|||
version "2.6.1" |
|||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" |
|||
dependencies: |
|||
glob "^7.0.5" |
|||
|
|||
wrappy@1: |
|||
version "1.0.2" |
|||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" |
@ -0,0 +1,67 @@ |
|||
# Neutrino Environment Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-env` is Neutrino middleware for injecting environment variable definitions into |
|||
source code at `process.env`. Always injects `process.env.NODE_ENV`, unless overridden. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-env` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-env |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-env |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-env` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const env = require('neutrino-middleware-env'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(env); |
|||
|
|||
// Usage with additional environment variables |
|||
neutrino.use(env, ['SECRET_KEY']); |
|||
``` |
|||
|
|||
This middleware optionally accepts an array of environment variables to additionally inject into source code. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-env` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `env`: Inject environment variables into source code at `process.env`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-env.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-env.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-env |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,5 @@ |
|||
const { EnvironmentPlugin } = require('webpack'); |
|||
|
|||
module.exports = ({ config }, envs = []) => config |
|||
.plugin('env') |
|||
.use(EnvironmentPlugin, ['NODE_ENV', ...(Array.isArray(envs) ? envs : [])]); |
@ -0,0 +1,24 @@ |
|||
{ |
|||
"name": "neutrino-middleware-env", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for injecting environment variables into source code", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"env", |
|||
"environment", |
|||
"variables" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-env", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"webpack": "^2.2.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,138 @@ |
|||
# Neutrino ESLint Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-eslint` is Neutrino middleware for linting source code using ESLint and eslint-loader. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-eslint` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-eslint |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-eslint |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-eslint` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const eslint = require('neutrino-middleware-eslint'); |
|||
|
|||
// Usage shows default values |
|||
neutrino.use(eslint, { |
|||
test: /\.(js|jsx)$/, |
|||
include: [], /* Should specify either include or exclude */ |
|||
exclude: [], /* Should specify either include or exclude */ |
|||
eslint: { |
|||
failOnError: process.env.NODE_ENV !== 'development', |
|||
emitWarning: process.env.NODE_ENV !== 'development', |
|||
emitError: process.env.NODE_ENV !== 'development', |
|||
cwd: neutrino.options.root, |
|||
useEslintrc: false, |
|||
root: true, |
|||
plugins: ['babel'], |
|||
baseConfig: {}, |
|||
envs: ['es6'], |
|||
parser: 'babel-eslint', |
|||
parserOptions: { |
|||
ecmaVersion: 2017, |
|||
sourceType: 'module', |
|||
ecmaFeatures: { |
|||
objectLiteralDuplicateProperties: false, |
|||
generators: true, |
|||
impliedStrict: true |
|||
} |
|||
}, |
|||
settings: {}, |
|||
globals: ['process'], |
|||
rules: {} |
|||
} |
|||
}); |
|||
``` |
|||
|
|||
- `test`: Test which files should be linted. |
|||
- `include`: An array of paths to include in linting. Maps to Webpack's |
|||
[`Rule.include`](https://webpack.js.org/configuration/module/#rule-include) |
|||
- `exclude`: An array of paths to exclude from linting. Maps to Webpack's |
|||
[`Rule.exclude`](https://webpack.js.org/configuration/module/#rule-exclude) |
|||
- `eslint`: An ESLint CLIEngine configuration object for configuring ESLint. Use this to configure rules, |
|||
plugins, and other [ESLint options](http://eslint.org/docs/user-guide/configuring). |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-eslint` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `lint`: By default, lints JS and JSX files from included directories using ESLint. Contains a single loader named |
|||
`eslint`. |
|||
|
|||
## Information |
|||
|
|||
This middleware will show errors and warnings in the console during development, and will cause a failure when |
|||
creating a build bundle. |
|||
|
|||
--- |
|||
|
|||
If you want your preset or middleware to also extend from another **ESLint configuration or preset** that you have made |
|||
a dependency, you must use `baseConfig.extends` rather than just `extends`. This is a limitation of ESLint, not this |
|||
middleware. |
|||
|
|||
--- |
|||
|
|||
This middleware only configures a target environment for `es6`, leaving other build middleware free to add their own |
|||
target environments. If your middleware puts restrictions on which environments it is capable of running, please |
|||
document that clearly in your middleware. |
|||
|
|||
## eslintrc Config |
|||
|
|||
`neutrino-middleware-eslint` 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](../../api/README.md) and providing the presets uses. |
|||
If you keep this information in `neutrino.presets` 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 presets will be |
|||
merged together for your development environment, without the need for copying, duplication, or loss of organization and |
|||
separation. |
|||
|
|||
_Example: Create a .eslintrc.js file in the root of the project._ |
|||
|
|||
```js |
|||
// .eslintrc.js |
|||
const Neutrino = require('neutrino'); |
|||
const pkg = require('./package.json'); |
|||
const api = new Neutrino(); |
|||
|
|||
pkg.neutrino.presets.map(preset => neutrino.use(preset)); |
|||
|
|||
module.exports = api.eslintrc(); |
|||
``` |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-eslint.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-eslint.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-eslint |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,64 @@ |
|||
const merge = require('deepmerge'); |
|||
const clone = require('lodash.clonedeep'); |
|||
const { join } = require('path'); |
|||
|
|||
const IF_NOT_DEV = process.env.NODE_ENV !== 'development'; |
|||
const MODULES = join(__dirname, 'node_modules'); |
|||
|
|||
module.exports = (neutrino, options) => { |
|||
const { config } = neutrino; |
|||
const lint = config.module.rule('lint'); |
|||
|
|||
config.resolve.modules.add(MODULES); |
|||
config.resolveLoader.modules.add(MODULES); |
|||
|
|||
lint |
|||
.test(options.test || /\.(js|jsx)$/) |
|||
.pre() |
|||
.use('eslint') |
|||
.loader(require.resolve('eslint-loader')) |
|||
.options(merge({ |
|||
failOnError: IF_NOT_DEV, |
|||
emitWarning: IF_NOT_DEV, |
|||
emitError: IF_NOT_DEV, |
|||
cwd: neutrino.options.root, |
|||
useEslintrc: false, |
|||
root: true, |
|||
plugins: ['babel'], |
|||
baseConfig: {}, |
|||
envs: ['es6'], |
|||
parser: 'babel-eslint', |
|||
parserOptions: { |
|||
ecmaVersion: 2017, |
|||
sourceType: 'module', |
|||
ecmaFeatures: { |
|||
objectLiteralDuplicateProperties: false, |
|||
generators: true, |
|||
impliedStrict: true |
|||
} |
|||
}, |
|||
settings: {}, |
|||
globals: ['process'], |
|||
rules: {} |
|||
}, options.eslint || {})); |
|||
|
|||
if (options.include) { |
|||
rule.include.merge(options.include); |
|||
} |
|||
|
|||
if (options.exclude) { |
|||
rule.exclude.merge(options.exclude); |
|||
} |
|||
|
|||
neutrino.eslintrc = () => { |
|||
const options = clone(config.module.rule('lint').use('eslint').get('options')); |
|||
|
|||
options.extends = options.baseConfig.extends; |
|||
options.useEslintrc = true; |
|||
options.env = options.envs.reduce((env, key) => Object.assign(env, { [key]: true }), {}); |
|||
options.globals = options.globals.reduce((globals, key) => Object.assign(globals, { [key]: true }), {}); |
|||
['envs', 'baseConfig', 'failOnError', 'emitWarning', 'emitError'].map(method => delete options[method]); |
|||
|
|||
return options; |
|||
}; |
|||
}; |
@ -0,0 +1,32 @@ |
|||
{ |
|||
"name": "neutrino-middleware-eslint", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for linting source code using ESLint", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"lint", |
|||
"eslint" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-eslint", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"babel-eslint": "^7.1.1", |
|||
"deepmerge": "^1.3.2", |
|||
"eslint": "^3.16.1", |
|||
"eslint-loader": "^1.6.3", |
|||
"eslint-plugin-babel": "^4.1.0", |
|||
"eslint-plugin-import": "^2.2.0", |
|||
"lodash.clonedeep": "^4.5.0" |
|||
}, |
|||
"devDependencies": { |
|||
"eslint-config-airbnb-base": "^11.1.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
@ -0,0 +1,70 @@ |
|||
# Neutrino Font Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-font-loader` is Neutrino middleware for loading and importing font files from modules. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-font-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-font-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-font-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-font-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const fonts = require('neutrino-middleware-font-loader'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(fonts); |
|||
|
|||
// Usage showing default options |
|||
neutrino.use(fonts, { |
|||
limit: '10000' |
|||
}); |
|||
``` |
|||
|
|||
- `limit`: Return a Data URL if the file is smaller than a byte limit. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-font-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `woff`: Allows importing WOFF font files from modules. Contains a single loader named `url`. |
|||
- `ttf`: Allows importing TTF font files from modules. Contains a single loader named `url`. |
|||
- `eot`: Allows importing EOT font files from modules. Contains a single loader named `file`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-font-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-font-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-font-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,27 @@ |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => { |
|||
const { limit } = merge({ limit: '10000' }, options); |
|||
const urlLoader = require.resolve('url-loader'); |
|||
const fileLoader = require.resolve('file-loader'); |
|||
|
|||
config.module |
|||
.rule('woff') |
|||
.test(/\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/) |
|||
.use('url') |
|||
.loader(urlLoader) |
|||
.options({ limit, mimetype: 'application/font-woff' }); |
|||
|
|||
config.module |
|||
.rule('ttf') |
|||
.test(/\.ttf(\?v=\d+\.\d+\.\d+)?$/) |
|||
.use('url') |
|||
.loader(urlLoader) |
|||
.options({ limit, mimetype: 'application/octet-stream' }); |
|||
|
|||
config.module |
|||
.rule('eot') |
|||
.test(/\.eot(\?v=\d+\.\d+\.\d+)?$/) |
|||
.use('file') |
|||
.loader(fileLoader); |
|||
}; |
@ -0,0 +1,24 @@ |
|||
{ |
|||
"name": "neutrino-middleware-font-loader", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for importing and loading font files from modules", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"font" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-font-loader", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"deepmerge": "^1.3.2", |
|||
"file-loader": "^0.10.1", |
|||
"url-loader": "^0.5.8" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
|||
big.js@^3.1.3: |
|||
version "3.1.3" |
|||
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" |
|||
|
|||
deepmerge@^1.3.2: |
|||
version "1.3.2" |
|||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.3.2.tgz#1663691629d4dbfe364fa12a2a4f0aa86aa3a050" |
|||
|
|||
emojis-list@^2.0.0: |
|||
version "2.1.0" |
|||
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" |
|||
|
|||
file-loader@^0.10.1: |
|||
version "0.10.1" |
|||
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.10.1.tgz#815034119891fc6441fb5a64c11bc93c22ddd842" |
|||
dependencies: |
|||
loader-utils "^1.0.2" |
|||
|
|||
json5@^0.5.0: |
|||
version "0.5.1" |
|||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" |
|||
|
|||
loader-utils@^1.0.2: |
|||
version "1.0.2" |
|||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.0.2.tgz#a9f923c865a974623391a8602d031137fad74830" |
|||
dependencies: |
|||
big.js "^3.1.3" |
|||
emojis-list "^2.0.0" |
|||
json5 "^0.5.0" |
|||
|
|||
mime@1.3.x: |
|||
version "1.3.4" |
|||
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" |
|||
|
|||
url-loader@^0.5.8: |
|||
version "0.5.8" |
|||
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.5.8.tgz#b9183b1801e0f847718673673040bc9dc1c715c5" |
|||
dependencies: |
|||
loader-utils "^1.0.2" |
|||
mime "1.3.x" |
@ -0,0 +1,61 @@ |
|||
# Neutrino Hot Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-hot` is Neutrino middleware for enabled Hot Module Replacement with Webpack's |
|||
`HotModuleReplacementPlugin`. This middleware is usually only added during development. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-hot` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-hot |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-hot |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-hot` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const hot = require('neutrino-middleware-hot'); |
|||
|
|||
neutrino.use(hot); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-hot` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `hot`: Enables hot module replacement. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-hot.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-hot.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-hot |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,3 @@ |
|||
const { HotModuleReplacementPlugin } = require('webpack'); |
|||
|
|||
module.exports = ({ config }) => config.plugin('hot').use(HotModuleReplacementPlugin); |
@ -0,0 +1,25 @@ |
|||
{ |
|||
"name": "neutrino-middleware-hot", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for plugging hot module replacement", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"hmr", |
|||
"hot", |
|||
"module", |
|||
"replacement" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-hot", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"webpack": "^2.2.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,60 @@ |
|||
# Neutrino HTML Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-html-loader` is Neutrino middleware for loading and importing HTML files from modules. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-html-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-html-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-html-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-html-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const html = require('neutrino-middleware-html-loader'); |
|||
|
|||
neutrino.use(html); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-html-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `html`: Allows importing HTML files from modules. Contains a single loader named `file`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-html-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-html-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-html-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,6 @@ |
|||
module.exports = ({ config }) => config.module |
|||
.rule('html') |
|||
.test(/\.html$/) |
|||
.use('file') |
|||
.loader(require.resolve('file-loader')) |
|||
.options({ name: '[name].[ext]' }); |
@ -0,0 +1,22 @@ |
|||
{ |
|||
"name": "neutrino-middleware-html-loader", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for importing and loading HTML files from modules", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"html" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-html-loader", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"file-loader": "^0.10.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
|||
big.js@^3.1.3: |
|||
version "3.1.3" |
|||
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" |
|||
|
|||
emojis-list@^2.0.0: |
|||
version "2.1.0" |
|||
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" |
|||
|
|||
file-loader@^0.10.1: |
|||
version "0.10.1" |
|||
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.10.1.tgz#815034119891fc6441fb5a64c11bc93c22ddd842" |
|||
dependencies: |
|||
loader-utils "^1.0.2" |
|||
|
|||
json5@^0.5.0: |
|||
version "0.5.1" |
|||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" |
|||
|
|||
loader-utils@^1.0.2: |
|||
version "1.0.2" |
|||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.0.2.tgz#a9f923c865a974623391a8602d031137fad74830" |
|||
dependencies: |
|||
big.js "^3.1.3" |
|||
emojis-list "^2.0.0" |
|||
json5 "^0.5.0" |
@ -0,0 +1,75 @@ |
|||
# Neutrino HTML Template Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-html-template` is Neutrino middleware for automatically creating HTML files for configured |
|||
entry-points. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-html-template` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-html-template |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-html-template |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-html-template` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const template = require('neutrino-middleware-html-template'); |
|||
|
|||
// Usage shows default values |
|||
// Accepts options specified by HtmlWebpackTemplate |
|||
// https://github.com/jaketrent/html-webpack-template |
|||
neutrino.use(template, { |
|||
inject: false, |
|||
appMountId: 'root', |
|||
xhtml: true, |
|||
mobile: true, |
|||
minify: { |
|||
useShortDoctype: true, |
|||
keepClosingSlash: true, |
|||
collapseWhitespace: true, |
|||
preserveLineBreaks: true |
|||
} |
|||
}); |
|||
``` |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-html-template` creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes. |
|||
|
|||
### Plugins |
|||
|
|||
The following is a list of plugins and their identifiers which can be overridden: |
|||
|
|||
- `html`: Automatically generates HTML files for configured entry-points. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-html-template.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-html-template.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-html-template |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,21 @@ |
|||
const HtmlPlugin = require('html-webpack-plugin'); |
|||
const template = require('html-webpack-template'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => config |
|||
.plugin('html') |
|||
.use(HtmlPlugin, [ |
|||
merge({ |
|||
template, |
|||
inject: false, |
|||
appMountId: 'root', |
|||
xhtml: true, |
|||
mobile: true, |
|||
minify: { |
|||
useShortDoctype: true, |
|||
keepClosingSlash: true, |
|||
collapseWhitespace: true, |
|||
preserveLineBreaks: true, |
|||
} |
|||
}, options) |
|||
]); |
@ -0,0 +1,28 @@ |
|||
{ |
|||
"name": "neutrino-middleware-html-template", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for automatic HTML file generation from metadata", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"html", |
|||
"template" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-html-template", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"deepmerge": "^1.3.2", |
|||
"html-webpack-plugin": "^2.28.0", |
|||
"html-webpack-template": "^6.0.1" |
|||
}, |
|||
"devDependencies": { |
|||
"webpack": "^2.2.1" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,70 @@ |
|||
# Neutrino Image Loader Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-image-loader` is Neutrino middleware for loading and importing image files from modules. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-image-loader` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-image-loader |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-image-loader |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-image-loader` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const images = require('neutrino-middleware-image-loader'); |
|||
|
|||
// Use with default options |
|||
neutrino.use(images); |
|||
|
|||
// Usage showing default options |
|||
neutrino.use(images, { |
|||
limit: 8192 |
|||
}); |
|||
``` |
|||
|
|||
- `limit`: Return a Data URL if the file is smaller than a byte limit. |
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-image-loader` creates some conventions to make overriding the configuration easier once you are |
|||
ready to make changes. |
|||
|
|||
### Rules |
|||
|
|||
The following is a list of rules and their identifiers which can be overridden: |
|||
|
|||
- `img`: Allows importing JPEG, PNG, and GIF files from modules. Contains a single loader named `url`. |
|||
- `svg`: Allows importing SVG files from modules. Contains a single loader named `url`. |
|||
- `ico`: Allows importing ICO files from modules. Contains a single loader named `url`. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-image-loader.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-image-loader.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-image-loader |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,26 @@ |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => { |
|||
const { limit } = merge({ limit: 8192 }, options); |
|||
const urlLoader = require.resolve('url-loader'); |
|||
|
|||
config.module |
|||
.rule('svg') |
|||
.test(/\.svg(\?v=\d+\.\d+\.\d+)?$/) |
|||
.use('url') |
|||
.loader(urlLoader) |
|||
.options({ limit, mimetype: 'application/svg+xml' }); |
|||
|
|||
config.module |
|||
.rule('img') |
|||
.test(/\.(png|jpg|jpeg|gif)$/) |
|||
.use('url') |
|||
.loader(urlLoader) |
|||
.options({ limit }); |
|||
|
|||
config.module |
|||
.rule('ico') |
|||
.test(/\.ico(\?v=\d+\.\d+\.\d+)?$/) |
|||
.use('url') |
|||
.loader(urlLoader); |
|||
}; |
@ -0,0 +1,24 @@ |
|||
{ |
|||
"name": "neutrino-middleware-image-loader", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for importing and loading image files from modules", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"image" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-image-loader", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"deepmerge": "^1.3.2", |
|||
"file-loader": "^0.10.1", |
|||
"url-loader": "^0.5.8" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
|||
big.js@^3.1.3: |
|||
version "3.1.3" |
|||
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" |
|||
|
|||
deepmerge@^1.3.2: |
|||
version "1.3.2" |
|||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.3.2.tgz#1663691629d4dbfe364fa12a2a4f0aa86aa3a050" |
|||
|
|||
emojis-list@^2.0.0: |
|||
version "2.1.0" |
|||
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" |
|||
|
|||
file-loader@^0.10.1: |
|||
version "0.10.1" |
|||
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.10.1.tgz#815034119891fc6441fb5a64c11bc93c22ddd842" |
|||
dependencies: |
|||
loader-utils "^1.0.2" |
|||
|
|||
json5@^0.5.0: |
|||
version "0.5.1" |
|||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" |
|||
|
|||
loader-utils@^1.0.2: |
|||
version "1.0.2" |
|||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.0.2.tgz#a9f923c865a974623391a8602d031137fad74830" |
|||
dependencies: |
|||
big.js "^3.1.3" |
|||
emojis-list "^2.0.0" |
|||
json5 "^0.5.0" |
|||
|
|||
mime@1.3.x: |
|||
version "1.3.4" |
|||
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" |
|||
|
|||
url-loader@^0.5.8: |
|||
version "0.5.8" |
|||
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.5.8.tgz#b9183b1801e0f847718673673040bc9dc1c715c5" |
|||
dependencies: |
|||
loader-utils "^1.0.2" |
|||
mime "1.3.x" |
@ -0,0 +1,75 @@ |
|||
# Neutrino Loader Merge Middleware |
|||
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url] |
|||
|
|||
`neutrino-middleware-loader-merge` is Neutrino middleware for easily performing a deep merge of options into |
|||
a named rule and named loader in a Neutrino configuration. |
|||
|
|||
## Requirements |
|||
|
|||
- Node.js v6.9+ |
|||
- Yarn or npm client |
|||
- Neutrino v5 |
|||
|
|||
## Installation |
|||
|
|||
`neutrino-middleware-loader-merge` can be installed via the Yarn or npm clients. |
|||
|
|||
#### Yarn |
|||
|
|||
```bash |
|||
❯ yarn add neutrino-middleware-loader-merge |
|||
``` |
|||
|
|||
#### npm |
|||
|
|||
```bash |
|||
❯ npm install --save neutrino-middleware-loader-merge |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
`neutrino-middleware-loader-merge` can be consumed from the Neutrino API, middleware, or presets. Require this package |
|||
and plug it into Neutrino: |
|||
|
|||
```js |
|||
const loaderMerge = require('neutrino-middleware-loader-merge'); |
|||
|
|||
neutrino.use(loaderMerge('compile', 'babel'), { |
|||
plugins: ['object-rest-spread'] |
|||
}); |
|||
|
|||
// Equivalent to: |
|||
neutrino.config.module |
|||
.rule('compile') |
|||
.use('babel') |
|||
.tap(options => require('deepmerge')(options, { |
|||
plugins: ['object-rest-spread'] |
|||
})); |
|||
``` |
|||
|
|||
This middleware is a factory intended to be invoked with a rule name and a loader name for which to extend the options. |
|||
Upon invoking, it will return a middleware function to be provided to Neutrino's `use()` method. |
|||
|
|||
```js |
|||
const middleware = loaderMerge(ruleName, loaderName); |
|||
|
|||
neutrino.use(middleware, options); |
|||
``` |
|||
|
|||
|
|||
## Customization |
|||
|
|||
`neutrino-middleware-loader-merge` does not create any of its own conventions; it is only middleware |
|||
for extending the options for a rule loader which has create its own conventions. |
|||
|
|||
## Contributing |
|||
|
|||
This preset is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
[contributing guide](https://neutrino.js.org/contributing) for details. |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/neutrino-middleware-loader-merge.svg |
|||
[npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-loader-merge.svg |
|||
[npm-url]: https://npmjs.org/package/neutrino-middleware-loader-merge |
|||
[slack-image]: https://neutrino-slack.herokuapp.com/badge.svg |
|||
[slack-url]: https://neutrino-slack.herokuapp.com/ |
@ -0,0 +1,6 @@ |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = (ruleId, loaderId) => ({ config }, options) => config.module |
|||
.rule(ruleId) |
|||
.use(loaderId) |
|||
.tap(opts => merge(opts, options)); |
@ -0,0 +1,24 @@ |
|||
{ |
|||
"name": "neutrino-middleware-loader-merge", |
|||
"version": "5.0.0", |
|||
"description": "Neutrino middleware for merging options into existing ruleset loader options", |
|||
"main": "index.js", |
|||
"keywords": [ |
|||
"neutrino", |
|||
"neutrino-middleware", |
|||
"rule", |
|||
"loader", |
|||
"merge" |
|||
], |
|||
"author": "Eli Perelman <eli@eliperelman.com>", |
|||
"license": "MPL-2.0", |
|||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/neutrino-middleware-loader-merge", |
|||
"homepage": "https://neutrino.js.org", |
|||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", |
|||
"dependencies": { |
|||
"deepmerge": "^1.3.2" |
|||
}, |
|||
"peerDependencies": { |
|||
"neutrino": "^5.0.0" |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
|||
deepmerge@^1.3.2: |
|||
version "1.3.2" |
|||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.3.2.tgz#1663691629d4dbfe364fa12a2a4f0aa86aa3a050" |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue