UNPKG

2.36 kBMarkdownView Raw
1# Neutrino Chunk Middleware
2
3`@neutrinojs/chunk` is Neutrino middleware for optimizing webpack bundles via `CommonsChunkPlugin`.
4
5[![NPM version][npm-image]][npm-url]
6[![NPM downloads][npm-downloads]][npm-url]
7[![Join the Neutrino community on Spectrum][spectrum-image]][spectrum-url]
8
9## Requirements
10
11- Node.js v6 LTS, v8, v9
12- Yarn v1.2.1+, or npm v5.4+
13- Neutrino v8
14
15## Installation
16
17`@neutrinojs/chunk` can be installed via the Yarn or npm clients.
18
19#### Yarn
20
21```bash
22❯ yarn add @neutrinojs/chunk
23```
24
25#### npm
26
27```bash
28❯ npm install --save @neutrinojs/chunk
29```
30
31## Usage
32
33`@neutrinojs/chunk` can be consumed from the Neutrino API, middleware, or presets. Require this package
34and plug it into Neutrino:
35
36```js
37// Using function middleware format
38const chunk = require('@neutrinojs/chunk');
39
40neutrino.use(chunk);
41```
42
43```js
44// Using object or array middleware format
45
46module.exports = {
47 use: ['@neutrinojs/chunk']
48};
49```
50
51## Customization
52
53`@neutrinojs/chunk` creates some conventions to make overriding the configuration easier once you are ready to
54make changes.
55
56### Plugins
57
58The following is a list of plugins and their identifiers which can be overridden:
59
60| Name | Description | Environments and Commands |
61| --- | --- | --- |
62| `named-modules` | Enables named modules for improved debugging and console output. | all |
63| `named-chunks` | Enables named chunks for improved debugging and console output. | all |
64| `vendor-chunk` | Creates a separate file/chunk consisting of common modules shared between multiple entry points. | all |
65| `runtime-chunk` | Creates a separate file/chunk consisting of the webpack manifest-specific code. | all |
66| `name-all` | Names all remaining modules that do not get named via `named-modules`. | all |
67
68## Contributing
69
70This middleware is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo
71containing all resources for developing Neutrino and its core presets and middleware. Follow the
72[contributing guide](https://neutrino.js.org/contributing) for details.
73
74[npm-image]: https://img.shields.io/npm/v/@neutrinojs/chunk.svg
75[npm-downloads]: https://img.shields.io/npm/dt/@neutrinojs/chunk.svg
76[npm-url]: https://npmjs.org/package/@neutrinojs/chunk
77[spectrum-image]: https://withspectrum.github.io/badge/badge.svg
78[spectrum-url]: https://spectrum.chat/neutrino