UNPKG

2.82 kBMarkdownView Raw
1# Neutrino Banner Middleware
2
3`@neutrinojs/banner` is Neutrino middleware for injecting string content into source code files.
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/banner` can be installed via the Yarn or npm clients.
18
19#### Yarn
20
21```bash
22❯ yarn add @neutrinojs/banner
23```
24
25#### npm
26
27```bash
28❯ npm install --save @neutrinojs/banner
29```
30
31## Usage
32
33`@neutrinojs/banner` 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 banner = require('@neutrinojs/banner');
39
40// Use with default options
41neutrino.use(banner);
42
43// Also accepts options for webpack's BannerPlugin
44// https://webpack.js.org/plugins/banner-plugin/
45
46// Usage shows the default values of this middleware:
47neutrino.use(banner, {
48 banner: `require('source-map-support').install();`,
49 raw: true,
50 entryOnly: true,
51 // Override pluginId to add an additional banner plugin instance
52 pluginId: 'banner'
53});
54```
55
56```js
57// Using object or array middleware format:
58const banner = require('@neutrinojs/banner');
59
60// Use with default options
61module.exports = {
62 use: ['@neutrinojs/banner']
63};
64
65// Also accepts options for webpack's BannerPlugin
66// https://webpack.js.org/plugins/banner-plugin/
67
68// Usage shows the default values of this middleware:
69module.exports = {
70 use: [
71 ['@neutrinojs/banner', {
72 banner: `require('source-map-support').install();`,
73 raw: true,
74 entryOnly: true,
75 // Override pluginId to add an additional banner plugin instance
76 pluginId: 'banner'
77 }]
78 ]
79};
80```
81
82## Customization
83
84`@neutrinojs/banner` creates some conventions to make overriding the configuration easier once you are ready to
85make changes.
86
87### Plugins
88
89The following is a list of plugins and their identifiers which can be overridden:
90
91| Name | Description | Environments and Commands |
92| --- | --- | --- |
93| `banner` | Injects string content into application source code. | all |
94
95## Contributing
96
97This middleware is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo
98containing all resources for developing Neutrino and its core presets and middleware. Follow the
99[contributing guide](https://neutrino.js.org/contributing) for details.
100
101[npm-image]: https://img.shields.io/npm/v/@neutrinojs/banner.svg
102[npm-downloads]: https://img.shields.io/npm/dt/@neutrinojs/banner.svg
103[npm-url]: https://npmjs.org/package/@neutrinojs/banner
104[spectrum-image]: https://withspectrum.github.io/badge/badge.svg
105[spectrum-url]: https://spectrum.chat/neutrino