committed by
GitHub
46 changed files with 1515 additions and 5357 deletions
@ -1,720 +0,0 @@ |
|||
|
|||
<!DOCTYPE HTML> |
|||
<html lang="" > |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
|||
<title>Middleware · Neutrino</title> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
|||
<meta name="description" content=""> |
|||
<meta name="generator" content="GitBook 3.2.2"> |
|||
|
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../gitbook/style.css"> |
|||
|
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-npmsearchlist/styles.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css"> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<meta name="HandheldFriendly" content="true"/> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
|||
<meta name="apple-mobile-web-app-capable" content="yes"> |
|||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> |
|||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png"> |
|||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon"> |
|||
|
|||
|
|||
<link rel="next" href="../presets/" /> |
|||
|
|||
|
|||
<link rel="prev" href="../FAQ.html" /> |
|||
|
|||
|
|||
</head> |
|||
<body> |
|||
|
|||
<div class="book"> |
|||
<div class="book-summary"> |
|||
|
|||
|
|||
<div id="book-search-input" role="search"> |
|||
<input type="text" placeholder="Type to search" /> |
|||
</div> |
|||
|
|||
|
|||
<nav role="navigation"> |
|||
|
|||
|
|||
|
|||
<ul class="summary"> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<li class="chapter " data-level="1.1" data-path="../"> |
|||
|
|||
<a href="../"> |
|||
|
|||
|
|||
Introduction |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.2" data-path="../installation.html"> |
|||
|
|||
<a href="../installation.html"> |
|||
|
|||
|
|||
Installation |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.3" data-path="../usage.html"> |
|||
|
|||
<a href="../usage.html"> |
|||
|
|||
|
|||
Usage |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.4" data-path="../project-layout.html"> |
|||
|
|||
<a href="../project-layout.html"> |
|||
|
|||
|
|||
Project Layout |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.5" data-path="../FAQ.html"> |
|||
|
|||
<a href="../FAQ.html"> |
|||
|
|||
|
|||
FAQ |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter active" data-level="1.6" data-path="./"> |
|||
|
|||
<a href="./"> |
|||
|
|||
|
|||
Middleware |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7" data-path="../presets/"> |
|||
|
|||
<a href="../presets/"> |
|||
|
|||
|
|||
Presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.7.1" data-path="../presets/neutrino-preset-web/"> |
|||
|
|||
<a href="../presets/neutrino-preset-web/"> |
|||
|
|||
|
|||
Web |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.2" data-path="../presets/neutrino-preset-react/"> |
|||
|
|||
<a href="../presets/neutrino-preset-react/"> |
|||
|
|||
|
|||
React |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.3" data-path="../presets/neutrino-preset-node/"> |
|||
|
|||
<a href="../presets/neutrino-preset-node/"> |
|||
|
|||
|
|||
Node.js |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.4" data-path="../presets/neutrino-preset-airbnb-base/"> |
|||
|
|||
<a href="../presets/neutrino-preset-airbnb-base/"> |
|||
|
|||
|
|||
Airbnb |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.5" data-path="../presets/neutrino-preset-karma/"> |
|||
|
|||
<a href="../presets/neutrino-preset-karma/"> |
|||
|
|||
|
|||
Karma |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.6" data-path="../presets/neutrino-preset-mocha/"> |
|||
|
|||
<a href="../presets/neutrino-preset-mocha/"> |
|||
|
|||
|
|||
Mocha |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.7" data-path="../presets/neutrino-preset-jest/"> |
|||
|
|||
<a href="../presets/neutrino-preset-jest/"> |
|||
|
|||
|
|||
Jest |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.8" data-path="../presets/community-presets.html"> |
|||
|
|||
<a href="../presets/community-presets.html"> |
|||
|
|||
|
|||
Community presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.8" data-path="../customization/"> |
|||
|
|||
<a href="../customization/"> |
|||
|
|||
|
|||
Customization |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.8.1" data-path="../customization/simple.html"> |
|||
|
|||
<a href="../customization/simple.html"> |
|||
|
|||
|
|||
Simple |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.8.2" data-path="../customization/advanced.html"> |
|||
|
|||
<a href="../customization/advanced.html"> |
|||
|
|||
|
|||
Advanced |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.9" data-path="../creating-presets.html"> |
|||
|
|||
<a href="../creating-presets.html"> |
|||
|
|||
|
|||
Creating presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.9.1" data-path="../presets/neutrino-lint-base/README.md"> |
|||
|
|||
<span> |
|||
|
|||
|
|||
Creating linting presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.10" data-path="../learning-resources.html"> |
|||
|
|||
<a href="../learning-resources.html"> |
|||
|
|||
|
|||
Learning Resources |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.11" data-path="../api/"> |
|||
|
|||
<a href="../api/"> |
|||
|
|||
|
|||
API |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.12" data-path="../cli/"> |
|||
|
|||
<a href="../cli/"> |
|||
|
|||
|
|||
CLI |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.13" data-path="../upgrading-neutrino.html"> |
|||
|
|||
<a href="../upgrading-neutrino.html"> |
|||
|
|||
|
|||
Upgrading from v4 to v5 |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.14" > |
|||
|
|||
<a target="_blank" href="https://github.com/mozilla-neutrino/neutrino-dev/tree/docs-v4/docs"> |
|||
|
|||
|
|||
v4 Documentation |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.15" data-path="../contributing/"> |
|||
|
|||
<a href="../contributing/"> |
|||
|
|||
|
|||
Contributing |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.15.1" data-path="../contributing/development.html"> |
|||
|
|||
<a href="../contributing/development.html"> |
|||
|
|||
|
|||
Development Process |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.15.2" data-path="../contributing/code-of-conduct.html"> |
|||
|
|||
<a href="../contributing/code-of-conduct.html"> |
|||
|
|||
|
|||
Code of Conduct |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
|
|||
|
|||
|
|||
<li class="divider"></li> |
|||
|
|||
<li> |
|||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
|||
Published with GitBook |
|||
</a> |
|||
</li> |
|||
</ul> |
|||
|
|||
|
|||
</nav> |
|||
|
|||
|
|||
</div> |
|||
|
|||
<div class="book-body"> |
|||
|
|||
<div class="body-inner"> |
|||
|
|||
|
|||
|
|||
<div class="book-header" role="navigation"> |
|||
|
|||
|
|||
<!-- Title --> |
|||
<h1> |
|||
<i class="fa fa-circle-o-notch fa-spin"></i> |
|||
<a href=".." >Middleware</a> |
|||
</h1> |
|||
</div> |
|||
|
|||
|
|||
|
|||
|
|||
<div class="page-wrapper" tabindex="-1" role="main"> |
|||
<div class="page-inner"> |
|||
|
|||
<div id="book-search-results"> |
|||
<div class="search-noresults"> |
|||
|
|||
<section class="normal markdown-section"> |
|||
|
|||
<h1 id="middleware">Middleware</h1> |
|||
<p>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:</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">middleware</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> |
|||
</code></pre> |
|||
<p>A middleware function can also optionally accept an <code>options</code> argument which will be fed back into |
|||
the middleware function when used.</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">middleware</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">,</span> options<span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> |
|||
</code></pre> |
|||
<p>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.</p> |
|||
<p>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 <code>use()</code> method.</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">const</span> api <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Neutrino</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
api<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>middleware<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
api<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>middleware<span class="token punctuation">,</span> options<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<p>To use a concrete example, let's create middleware that adds an environment plugin:</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">const</span> Neutrino <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> <span class="token punctuation">{</span> EnvironmentPlugin <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'webpack'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token keyword">const</span> api <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Neutrino</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token keyword">function</span> <span class="token function">env</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">,</span> additionalVars <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> |
|||
neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">plugin</span><span class="token punctuation">(</span><span class="token string">'env'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>EnvironmentPlugin<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'NODE_ENV'</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>additionalVars<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token punctuation">}</span> |
|||
|
|||
api<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>env<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">// or:</span> |
|||
api<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>env<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'SECRET_KEY'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<h2 id="loading-middleware">Loading middleware</h2> |
|||
<p>Additional middleware can also be loaded from a middleware function. This makes their composition simpler for |
|||
consumers.</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// neutrino-middleware-env</span> |
|||
<span class="token keyword">const</span> <span class="token punctuation">{</span> EnvironmentPlugin <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'webpack'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">(</span>neutrino<span class="token punctuation">,</span> additionalVars <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">plugin</span><span class="token punctuation">(</span><span class="token string">'env'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>EnvironmentPlugin<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'NODE_ENV'</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>additionalVars<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// react preset (which is also middleware)</span> |
|||
<span class="token keyword">const</span> env <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'./neutrino-middleware-env'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> neutrino <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
neutrino<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>env<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'SECRET_KEY'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
neutrino<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token comment" spellcheck="true">/* next middleware */</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
neutrino<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token comment" spellcheck="true">/* next middleware */</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<h2 id="configuring">Configuring</h2> |
|||
<p>If your middleware requires configuration <em>outside</em> of the options necessary for <em>running</em> 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:</p> |
|||
<pre class="language-"><code class="lang-js">module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token function">wrapper</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>args<span class="token punctuation">)</span> <span class="token punctuation">{</span> |
|||
<span class="token keyword">return</span> <span class="token keyword">function</span> <span class="token function">middleware</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">,</span> options<span class="token punctuation">)</span> <span class="token punctuation">{</span> |
|||
<span class="token comment" spellcheck="true">// do something with neutrino, options, and args</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<p>Let's create a contrived example using our <code>env</code> middleware. Let's use a closure to let the consumer provide an |
|||
alternate plugin name when creating the middleware:</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// neutrino-middleware-env</span> |
|||
<span class="token keyword">const</span> <span class="token punctuation">{</span> EnvironmentPlugin <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'webpack'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">(</span>pluginName <span class="token operator">=</span> <span class="token string">'env'</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">(</span>neutrino<span class="token punctuation">,</span> additionalVars <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">plugin</span><span class="token punctuation">(</span>pluginName<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>EnvironmentPlugin<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'NODE_ENV'</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>additionalVars<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// react preset (which is also middleware)</span> |
|||
<span class="token keyword">const</span> env <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'./neutrino-middleware-env'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> neutrino <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
neutrino<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token function">env</span><span class="token punctuation">(</span><span class="token string">'ENV-PLUGIN'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'SECRET_KEY'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<h2 id="distributing">Distributing</h2> |
|||
<p>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.</p> |
|||
<h2 id="core-middleware">Core middleware</h2> |
|||
<p>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.</p> |
|||
|
|||
|
|||
</section> |
|||
|
|||
</div> |
|||
<div class="search-results"> |
|||
<div class="has-results"> |
|||
|
|||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1> |
|||
<ul class="search-results-list"></ul> |
|||
|
|||
</div> |
|||
<div class="no-results"> |
|||
|
|||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
|
|||
|
|||
<a href="../FAQ.html" class="navigation navigation-prev " aria-label="Previous page: FAQ"> |
|||
<i class="fa fa-angle-left"></i> |
|||
</a> |
|||
|
|||
|
|||
<a href="../presets/" class="navigation navigation-next " aria-label="Next page: Presets"> |
|||
<i class="fa fa-angle-right"></i> |
|||
</a> |
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
<script> |
|||
var gitbook = gitbook || []; |
|||
gitbook.push(function() { |
|||
gitbook.page.hasChanged({"page":{"title":"Middleware","level":"1.6","depth":1,"next":{"title":"Presets","level":"1.7","depth":1,"path":"presets/README.md","ref":"./presets/README.md","articles":[{"title":"Web","level":"1.7.1","depth":2,"path":"presets/neutrino-preset-web/README.md","ref":"./presets/neutrino-preset-web/README.md","articles":[]},{"title":"React","level":"1.7.2","depth":2,"path":"presets/neutrino-preset-react/README.md","ref":"./presets/neutrino-preset-react/README.md","articles":[]},{"title":"Node.js","level":"1.7.3","depth":2,"path":"presets/neutrino-preset-node/README.md","ref":"./presets/neutrino-preset-node/README.md","articles":[]},{"title":"Airbnb","level":"1.7.4","depth":2,"path":"presets/neutrino-preset-airbnb-base/README.md","ref":"./presets/neutrino-preset-airbnb-base/README.md","articles":[]},{"title":"Karma","level":"1.7.5","depth":2,"path":"presets/neutrino-preset-karma/README.md","ref":"./presets/neutrino-preset-karma/README.md","articles":[]},{"title":"Mocha","level":"1.7.6","depth":2,"path":"presets/neutrino-preset-mocha/README.md","ref":"./presets/neutrino-preset-mocha/README.md","articles":[]},{"title":"Jest","level":"1.7.7","depth":2,"path":"presets/neutrino-preset-jest/README.md","ref":"./presets/neutrino-preset-jest/README.md","articles":[]},{"title":"Community presets","level":"1.7.8","depth":2,"path":"presets/community-presets.md","ref":"./presets/community-presets.md","articles":[]}]},"previous":{"title":"FAQ","level":"1.5","depth":1,"path":"FAQ.md","ref":"./FAQ.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","prism","-highlight","github","anchorjs","npmsearchlist"],"root":"./docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/mozilla-neutrino/neutrino-dev/"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"npmsearchlist":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit page","base":"https://github.com/mozilla-neutrino/neutrino-dev/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchorjs":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Neutrino","gitbook":"*"},"file":{"path":"middleware/README.md","mtime":"2017-03-15T13:20:51.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-03-15T14:46:02.288Z"},"basePath":"..","book":{"language":""}}); |
|||
}); |
|||
</script> |
|||
</div> |
|||
|
|||
|
|||
<script src="../gitbook/gitbook.js"></script> |
|||
<script src="../gitbook/theme.js"></script> |
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-github/plugin.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/3.1.1/anchor.min.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-anchorjs/anchor-style.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-npmsearchlist/script.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-search/search.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script> |
|||
|
|||
|
|||
|
|||
</body> |
|||
</html> |
|||
|
@ -1,71 +0,0 @@ |
|||
# 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/ |
@ -1,71 +0,0 @@ |
|||
# 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/ |
@ -1,67 +0,0 @@ |
|||
# 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/ |
@ -1,69 +0,0 @@ |
|||
# 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/ |
@ -1,73 +0,0 @@ |
|||
# 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/ |
@ -1,67 +0,0 @@ |
|||
# 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/ |
@ -1,138 +0,0 @@ |
|||
# 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/ |
@ -1,70 +0,0 @@ |
|||
# 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/ |
@ -1,61 +0,0 @@ |
|||
# 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/ |
@ -1,60 +0,0 @@ |
|||
# 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/ |
@ -1,75 +0,0 @@ |
|||
# 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/ |
@ -1,70 +0,0 @@ |
|||
# 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/ |
@ -1,75 +0,0 @@ |
|||
# 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/ |
@ -1,62 +0,0 @@ |
|||
# 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/ |
@ -1,60 +0,0 @@ |
|||
# 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/ |
@ -1,60 +0,0 @@ |
|||
# 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/ |
@ -1,69 +0,0 @@ |
|||
# 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/ |
@ -1,61 +0,0 @@ |
|||
# 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/ |
@ -0,0 +1,736 @@ |
|||
|
|||
<!DOCTYPE HTML> |
|||
<html lang="" > |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
|||
<title>Creating linting presets · Neutrino</title> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
|||
<meta name="description" content=""> |
|||
<meta name="generator" content="GitBook 3.2.2"> |
|||
|
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../../gitbook/style.css"> |
|||
|
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-npmsearchlist/styles.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css"> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<meta name="HandheldFriendly" content="true"/> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
|||
<meta name="apple-mobile-web-app-capable" content="yes"> |
|||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> |
|||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png"> |
|||
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon"> |
|||
|
|||
|
|||
<link rel="next" href="../../learning-resources.html" /> |
|||
|
|||
|
|||
<link rel="prev" href="../../creating-presets.html" /> |
|||
|
|||
|
|||
</head> |
|||
<body> |
|||
|
|||
<div class="book"> |
|||
<div class="book-summary"> |
|||
|
|||
|
|||
<div id="book-search-input" role="search"> |
|||
<input type="text" placeholder="Type to search" /> |
|||
</div> |
|||
|
|||
|
|||
<nav role="navigation"> |
|||
|
|||
|
|||
|
|||
<ul class="summary"> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<li class="chapter " data-level="1.1" data-path="../../"> |
|||
|
|||
<a href="../../"> |
|||
|
|||
|
|||
Introduction |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.2" data-path="../../installation.html"> |
|||
|
|||
<a href="../../installation.html"> |
|||
|
|||
|
|||
Installation |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.3" data-path="../../usage.html"> |
|||
|
|||
<a href="../../usage.html"> |
|||
|
|||
|
|||
Usage |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.4" data-path="../../project-layout.html"> |
|||
|
|||
<a href="../../project-layout.html"> |
|||
|
|||
|
|||
Project Layout |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.5" data-path="../../FAQ.html"> |
|||
|
|||
<a href="../../FAQ.html"> |
|||
|
|||
|
|||
FAQ |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6" data-path="../"> |
|||
|
|||
<a href="../"> |
|||
|
|||
|
|||
Presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.6.1" data-path="../neutrino-preset-web/"> |
|||
|
|||
<a href="../neutrino-preset-web/"> |
|||
|
|||
|
|||
Web |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6.2" data-path="../neutrino-preset-react/"> |
|||
|
|||
<a href="../neutrino-preset-react/"> |
|||
|
|||
|
|||
React |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6.3" data-path="../neutrino-preset-node/"> |
|||
|
|||
<a href="../neutrino-preset-node/"> |
|||
|
|||
|
|||
Node.js |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6.4" data-path="../neutrino-preset-airbnb-base/"> |
|||
|
|||
<a href="../neutrino-preset-airbnb-base/"> |
|||
|
|||
|
|||
Airbnb |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6.5" data-path="../neutrino-preset-karma/"> |
|||
|
|||
<a href="../neutrino-preset-karma/"> |
|||
|
|||
|
|||
Karma |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6.6" data-path="../neutrino-preset-mocha/"> |
|||
|
|||
<a href="../neutrino-preset-mocha/"> |
|||
|
|||
|
|||
Mocha |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6.7" data-path="../neutrino-preset-jest/"> |
|||
|
|||
<a href="../neutrino-preset-jest/"> |
|||
|
|||
|
|||
Jest |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6.8" data-path="../community-presets.html"> |
|||
|
|||
<a href="../community-presets.html"> |
|||
|
|||
|
|||
Community presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7" data-path="../../customization/"> |
|||
|
|||
<a href="../../customization/"> |
|||
|
|||
|
|||
Customization |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.7.1" data-path="../../customization/simple.html"> |
|||
|
|||
<a href="../../customization/simple.html"> |
|||
|
|||
|
|||
Simple |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.2" data-path="../../customization/advanced.html"> |
|||
|
|||
<a href="../../customization/advanced.html"> |
|||
|
|||
|
|||
Advanced |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.8" data-path="../../creating-presets.html"> |
|||
|
|||
<a href="../../creating-presets.html"> |
|||
|
|||
|
|||
Creating presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter active" data-level="1.8.1" data-path="./"> |
|||
|
|||
<a href="./"> |
|||
|
|||
|
|||
Creating linting presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.9" data-path="../../learning-resources.html"> |
|||
|
|||
<a href="../../learning-resources.html"> |
|||
|
|||
|
|||
Learning Resources |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.10" data-path="../../api/"> |
|||
|
|||
<a href="../../api/"> |
|||
|
|||
|
|||
API |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.11" data-path="../../cli/"> |
|||
|
|||
<a href="../../cli/"> |
|||
|
|||
|
|||
CLI |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.12" data-path="../../contributing/"> |
|||
|
|||
<a href="../../contributing/"> |
|||
|
|||
|
|||
Contributing |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.12.1" data-path="../../contributing/development.html"> |
|||
|
|||
<a href="../../contributing/development.html"> |
|||
|
|||
|
|||
Development Process |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.12.2" data-path="../../contributing/code-of-conduct.html"> |
|||
|
|||
<a href="../../contributing/code-of-conduct.html"> |
|||
|
|||
|
|||
Code of Conduct |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
|
|||
|
|||
|
|||
<li class="divider"></li> |
|||
|
|||
<li> |
|||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
|||
Published with GitBook |
|||
</a> |
|||
</li> |
|||
</ul> |
|||
|
|||
|
|||
</nav> |
|||
|
|||
|
|||
</div> |
|||
|
|||
<div class="book-body"> |
|||
|
|||
<div class="body-inner"> |
|||
|
|||
|
|||
|
|||
<div class="book-header" role="navigation"> |
|||
|
|||
|
|||
<!-- Title --> |
|||
<h1> |
|||
<i class="fa fa-circle-o-notch fa-spin"></i> |
|||
<a href="../.." >Creating linting presets</a> |
|||
</h1> |
|||
</div> |
|||
|
|||
|
|||
|
|||
|
|||
<div class="page-wrapper" tabindex="-1" role="main"> |
|||
<div class="page-inner"> |
|||
|
|||
<div id="book-search-results"> |
|||
<div class="search-noresults"> |
|||
|
|||
<section class="normal markdown-section"> |
|||
|
|||
<h1 id="neutrino-lint-base">Neutrino Lint Base</h1> |
|||
<p><a href="https://npmjs.org/package/neutrino-lint-base" target="_blank"><img src="https://img.shields.io/npm/v/neutrino-lint-base.svg" alt="NPM version"></a> <a href="https://npmjs.org/package/neutrino-lint-base" target="_blank"><img src="https://img.shields.io/npm/dt/neutrino-lint-base.svg" alt="NPM downloads"></a> <a href="https://neutrino-slack.herokuapp.com/" target="_blank"><img src="https://neutrino-slack.herokuapp.com/badge.svg" alt="Join Slack"></a></p> |
|||
<p><code>neutrino-lint-base</code> is an abstract Neutrino preset base that makes creating ESLint-based presets simpler. By creating |
|||
a linting preset that extends from <code>neutrino-lint-base</code>, 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.</p> |
|||
<h2 id="features">Features</h2> |
|||
<ul> |
|||
<li>Quickly and easily create your own Neutrino linting presets</li> |
|||
<li>Modern Babel knowledge supporting ES modules, JSX (when used with React preset), Web and Node.js apps</li> |
|||
<li>Highly visible during development, fails compilation when building for production</li> |
|||
<li>Easily extensible to customize your project as needed</li> |
|||
</ul> |
|||
<h2 id="development-requirements">Development Requirements</h2> |
|||
<ul> |
|||
<li>Node.js v6.9+</li> |
|||
<li>Yarn or npm client</li> |
|||
<li>Neutrino v4</li> |
|||
</ul> |
|||
<h2 id="installation">Installation</h2> |
|||
<p><code>neutrino-lint-base</code> can be installed via the Yarn or npm clients.</p> |
|||
<h4 id="yarn">Yarn</h4> |
|||
<pre class="language-"><code class="lang-bash">❯ yarn add neutrino-lint-base |
|||
</code></pre> |
|||
<h4 id="npm">npm</h4> |
|||
<pre class="language-"><code class="lang-bash">❯ npm <span class="token function">install</span> --save neutrino-lint-base |
|||
</code></pre> |
|||
<p>Your project should also install any dependencies needed to operate based on options passed to <code>eslint-loader</code> or |
|||
ESLint's CLIEngine.</p> |
|||
<h2 id="project-layout">Project Layout</h2> |
|||
<p><code>neutrino-lint-base</code> follows the standard <a href="../../project-layout.html">project layout</a> specified by Neutrino. This |
|||
means that by default all project source code should live in a directory named <code>src</code> in the root of the |
|||
project. The <code>.js</code> or <code>.jsx</code> files in this directory are the ones that will be linted by your preset.</p> |
|||
<h2 id="creating-the-preset">Creating the preset</h2> |
|||
<p>Your preset will follow the same guidelines for normally creating Neutrino presets, with your preset extending |
|||
<code>neutrino-lint-base</code>. This starts out by having your package module export a function which accepts a Neutrino instance:</p> |
|||
<pre class="language-"><code class="lang-js">module<span class="token punctuation">.</span>exports <span class="token operator">=</span> neutrino <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
<span class="token comment" spellcheck="true">// ...</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<p>The next step is to <code>require</code>, or <code>import</code> if your package supports it, <code>neutrino-lint-base</code> and execute it with |
|||
Neutrino. This will add the lint base's configuration to Neutrino for your preset to extend further:</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">const</span> lint <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino-lint-base'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> neutrino <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
<span class="token function">lint</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token comment" spellcheck="true">// ...</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<p>Now comes the core of your own preset. By extending from <code>neutrino-lint-base</code>'s "lint" rule and "eslint" loader, you |
|||
can manipulate the options as you desire. Consider using a package such as |
|||
<a href="https://www.npmjs.com/package/deepmerge" target="_blank"><code>deepmerge</code></a> to make extending these options easier:</p> |
|||
<p><em>Example: Create a preset that shuts off semicolons from being required by ESLint.</em></p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">const</span> lint <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino-lint-base'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> merge <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'deepmerge'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> neutrino <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
<span class="token function">lint</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'lint'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">'eslint'</span><span class="token punctuation">,</span> props <span class="token operator">=</span><span class="token operator">></span> <span class="token function">merge</span><span class="token punctuation">(</span>props<span class="token punctuation">,</span> <span class="token punctuation">{</span> |
|||
options<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
rules<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
semi<span class="token punctuation">:</span> <span class="token string">'off'</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<p><em>Example: Create a preset that lints a project using the Airbnb base ESLint rules.</em></p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">const</span> lint <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino-lint-base'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> merge <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'deepmerge'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> neutrino <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
<span class="token function">lint</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'lint'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">'eslint'</span><span class="token punctuation">,</span> props <span class="token operator">=</span><span class="token operator">></span> <span class="token function">merge</span><span class="token punctuation">(</span>props<span class="token punctuation">,</span> <span class="token punctuation">{</span> |
|||
options<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
baseConfig<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
<span class="token keyword">extends</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'airbnb-base'</span><span class="token punctuation">]</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<p>Visit the <a href="../../creating-presets.html">creating presets</a> documentation for more detailed information on creating your own |
|||
custom preset.</p> |
|||
<h2 id="customization">Customization</h2> |
|||
<p><code>neutrino-lint-base</code> creates some conventions to make overriding the configuration easier once you are ready to |
|||
make changes.</p> |
|||
<h3 id="rules">Rules</h3> |
|||
<p>The following is a list of rules and their identifiers which can be overridden:</p> |
|||
<ul> |
|||
<li><code>lint</code>: Lints JS and JSX files from the <code>src</code> directory using ESLint. Contains a single loader named <code>eslint</code>.</li> |
|||
</ul> |
|||
<h2 id="information">Information</h2> |
|||
<p>The lint base will show errors and warnings in the console during development, and will cause a failure when |
|||
creating a build bundle.</p> |
|||
<hr> |
|||
<p>If you want your preset to also extend from another ESLint configuration that you have made a dependency, you must use |
|||
<code>baseConfig.extends</code> rather than just <code>extends</code>. This is a limitation of ESLint, not this lint base.</p> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">const</span> lint <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino-lint-base'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> merge <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'deepmerge'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> neutrino <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span> |
|||
<span class="token function">lint</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'lint'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">'eslint'</span><span class="token punctuation">,</span> props <span class="token operator">=</span><span class="token operator">></span> <span class="token function">merge</span><span class="token punctuation">(</span>props<span class="token punctuation">,</span> <span class="token punctuation">{</span> |
|||
options<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
baseConfig<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
<span class="token keyword">extends</span><span class="token punctuation">:</span> <span class="token punctuation">[</span> |
|||
<span class="token string">'YOUR_ESLINT_CONFIGURATION_BASE_A'</span><span class="token punctuation">,</span> |
|||
<span class="token string">'YOUR_ESLINT_CONFIGURATION_BASE_B'</span> |
|||
<span class="token punctuation">]</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<hr> |
|||
<p>The linting base only configures a target environment for <code>es6</code>, 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.</p> |
|||
<p>For specifics on what options are configured when using this linting base, please |
|||
<a href="https://github.com/mozilla-neutrino/neutrino-dev/blob/master/packages/neutrino-lint-base/src/index.js" target="_blank">view the source</a>.</p> |
|||
<h2 id="eslintrc-config">eslintrc Config</h2> |
|||
<p><code>neutrino-lint-base</code> 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 <a href="../../api/">creating an instance of the Neutrino API</a> and providing the presets uses. If you |
|||
keep this information in <code>config.presets</code> 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.</p> |
|||
<p><em>Example: Create a .eslintrc.js file in the root of the project.</em></p> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// .eslintrc.js</span> |
|||
<span class="token keyword">const</span> Neutrino <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> pkg <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'./package.json'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> api <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Neutrino</span><span class="token punctuation">(</span>pkg<span class="token punctuation">.</span>config<span class="token punctuation">.</span>presets<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> api<span class="token punctuation">.</span>custom<span class="token punctuation">.</span><span class="token function">eslintrc</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<hr> |
|||
<h2 id="contributing">Contributing</h2> |
|||
<p>This preset is part of the <a href="https://github.com/mozilla-neutrino/neutrino-dev" target="_blank">neutrino-dev</a> repository, a monorepo |
|||
containing all resources for developing Neutrino and its core presets. Follow the |
|||
<a href="../../contributing/">contributing guide</a> for details.</p> |
|||
|
|||
|
|||
</section> |
|||
|
|||
</div> |
|||
<div class="search-results"> |
|||
<div class="has-results"> |
|||
|
|||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1> |
|||
<ul class="search-results-list"></ul> |
|||
|
|||
</div> |
|||
<div class="no-results"> |
|||
|
|||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
|
|||
|
|||
<a href="../../creating-presets.html" class="navigation navigation-prev " aria-label="Previous page: Creating presets"> |
|||
<i class="fa fa-angle-left"></i> |
|||
</a> |
|||
|
|||
|
|||
<a href="../../learning-resources.html" class="navigation navigation-next " aria-label="Next page: Learning Resources"> |
|||
<i class="fa fa-angle-right"></i> |
|||
</a> |
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
<script> |
|||
var gitbook = gitbook || []; |
|||
gitbook.push(function() { |
|||
gitbook.page.hasChanged({"page":{"title":"Creating linting presets","level":"1.8.1","depth":2,"next":{"title":"Learning Resources","level":"1.9","depth":1,"path":"learning-resources.md","ref":"learning-resources.md","articles":[]},"previous":{"title":"Creating presets","level":"1.8","depth":1,"path":"creating-presets.md","ref":"creating-presets.md","articles":[{"title":"Creating linting presets","level":"1.8.1","depth":2,"path":"presets/neutrino-lint-base/README.md","ref":"presets/neutrino-lint-base/README.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["edit-link","prism","-highlight","github","anchorjs","npmsearchlist"],"root":"./docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/mozilla-neutrino/neutrino-dev/"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"npmsearchlist":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit page","base":"https://github.com/mozilla-neutrino/neutrino-dev/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchorjs":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Neutrino","gitbook":"*"},"file":{"path":"presets/neutrino-lint-base/README.md","mtime":"2017-03-01T15:25:58.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-03-06T17:07:12.452Z"},"basePath":"../..","book":{"language":""}}); |
|||
}); |
|||
</script> |
|||
</div> |
|||
|
|||
|
|||
<script src="../../gitbook/gitbook.js"></script> |
|||
<script src="../../gitbook/theme.js"></script> |
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-github/plugin.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/3.1.1/anchor.min.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-anchorjs/anchor-style.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-npmsearchlist/script.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-search/search.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script> |
|||
|
|||
|
|||
|
|||
</body> |
|||
</html> |
|||
|
File diff suppressed because one or more lines are too long
@ -1,822 +0,0 @@ |
|||
|
|||
<!DOCTYPE HTML> |
|||
<html lang="" > |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
|||
<title>Upgrading from v4 to v5 · Neutrino</title> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
|||
<meta name="description" content=""> |
|||
<meta name="generator" content="GitBook 3.2.2"> |
|||
|
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="gitbook/style.css"> |
|||
|
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="gitbook/gitbook-plugin-prism/prism.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="gitbook/gitbook-plugin-npmsearchlist/styles.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css"> |
|||
|
|||
|
|||
|
|||
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css"> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<meta name="HandheldFriendly" content="true"/> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
|||
<meta name="apple-mobile-web-app-capable" content="yes"> |
|||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> |
|||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png"> |
|||
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon"> |
|||
|
|||
|
|||
|
|||
<link rel="prev" href="cli/" /> |
|||
|
|||
|
|||
</head> |
|||
<body> |
|||
|
|||
<div class="book"> |
|||
<div class="book-summary"> |
|||
|
|||
|
|||
<div id="book-search-input" role="search"> |
|||
<input type="text" placeholder="Type to search" /> |
|||
</div> |
|||
|
|||
|
|||
<nav role="navigation"> |
|||
|
|||
|
|||
|
|||
<ul class="summary"> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<li class="chapter " data-level="1.1" data-path="./"> |
|||
|
|||
<a href="./"> |
|||
|
|||
|
|||
Introduction |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.2" data-path="installation.html"> |
|||
|
|||
<a href="installation.html"> |
|||
|
|||
|
|||
Installation |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.3" data-path="usage.html"> |
|||
|
|||
<a href="usage.html"> |
|||
|
|||
|
|||
Usage |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.4" data-path="project-layout.html"> |
|||
|
|||
<a href="project-layout.html"> |
|||
|
|||
|
|||
Project Layout |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.5" data-path="FAQ.html"> |
|||
|
|||
<a href="FAQ.html"> |
|||
|
|||
|
|||
FAQ |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.6" data-path="middleware/"> |
|||
|
|||
<a href="middleware/"> |
|||
|
|||
|
|||
Middleware |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7" data-path="presets/"> |
|||
|
|||
<a href="presets/"> |
|||
|
|||
|
|||
Presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.7.1" data-path="presets/neutrino-preset-web/"> |
|||
|
|||
<a href="presets/neutrino-preset-web/"> |
|||
|
|||
|
|||
Web |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.2" data-path="presets/neutrino-preset-react/"> |
|||
|
|||
<a href="presets/neutrino-preset-react/"> |
|||
|
|||
|
|||
React |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.3" data-path="presets/neutrino-preset-node/"> |
|||
|
|||
<a href="presets/neutrino-preset-node/"> |
|||
|
|||
|
|||
Node.js |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.4" data-path="presets/neutrino-preset-airbnb-base/"> |
|||
|
|||
<a href="presets/neutrino-preset-airbnb-base/"> |
|||
|
|||
|
|||
Airbnb |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.5" data-path="presets/neutrino-preset-karma/"> |
|||
|
|||
<a href="presets/neutrino-preset-karma/"> |
|||
|
|||
|
|||
Karma |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.6" data-path="presets/neutrino-preset-mocha/"> |
|||
|
|||
<a href="presets/neutrino-preset-mocha/"> |
|||
|
|||
|
|||
Mocha |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.7" data-path="presets/neutrino-preset-jest/"> |
|||
|
|||
<a href="presets/neutrino-preset-jest/"> |
|||
|
|||
|
|||
Jest |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.7.8" data-path="presets/community-presets.html"> |
|||
|
|||
<a href="presets/community-presets.html"> |
|||
|
|||
|
|||
Community presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.8" data-path="customization/"> |
|||
|
|||
<a href="customization/"> |
|||
|
|||
|
|||
Customization |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.8.1" data-path="customization/simple.html"> |
|||
|
|||
<a href="customization/simple.html"> |
|||
|
|||
|
|||
Simple |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.8.2" data-path="customization/advanced.html"> |
|||
|
|||
<a href="customization/advanced.html"> |
|||
|
|||
|
|||
Advanced |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.9" data-path="creating-presets.html"> |
|||
|
|||
<a href="creating-presets.html"> |
|||
|
|||
|
|||
Creating presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.9.1" data-path="presets/neutrino-lint-base/README.md"> |
|||
|
|||
<span> |
|||
|
|||
|
|||
Creating linting presets |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.10" data-path="learning-resources.html"> |
|||
|
|||
<a href="learning-resources.html"> |
|||
|
|||
|
|||
Learning Resources |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.11" data-path="api/"> |
|||
|
|||
<a href="api/"> |
|||
|
|||
|
|||
API |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.12" data-path="cli/"> |
|||
|
|||
<a href="cli/"> |
|||
|
|||
|
|||
CLI |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter active" data-level="1.13" data-path="upgrading-neutrino.html"> |
|||
|
|||
<a href="upgrading-neutrino.html"> |
|||
|
|||
|
|||
Upgrading from v4 to v5 |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.14" > |
|||
|
|||
<a target="_blank" href="https://github.com/mozilla-neutrino/neutrino-dev/tree/docs-v4/docs"> |
|||
|
|||
|
|||
v4 Documentation |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.15" data-path="contributing/"> |
|||
|
|||
<a href="contributing/"> |
|||
|
|||
|
|||
Contributing |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
<ul class="articles"> |
|||
|
|||
|
|||
<li class="chapter " data-level="1.15.1" data-path="contributing/development.html"> |
|||
|
|||
<a href="contributing/development.html"> |
|||
|
|||
|
|||
Development Process |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
<li class="chapter " data-level="1.15.2" data-path="contributing/code-of-conduct.html"> |
|||
|
|||
<a href="contributing/code-of-conduct.html"> |
|||
|
|||
|
|||
Code of Conduct |
|||
|
|||
</a> |
|||
|
|||
|
|||
|
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
|
|||
</li> |
|||
|
|||
|
|||
|
|||
|
|||
<li class="divider"></li> |
|||
|
|||
<li> |
|||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
|||
Published with GitBook |
|||
</a> |
|||
</li> |
|||
</ul> |
|||
|
|||
|
|||
</nav> |
|||
|
|||
|
|||
</div> |
|||
|
|||
<div class="book-body"> |
|||
|
|||
<div class="body-inner"> |
|||
|
|||
|
|||
|
|||
<div class="book-header" role="navigation"> |
|||
|
|||
|
|||
<!-- Title --> |
|||
<h1> |
|||
<i class="fa fa-circle-o-notch fa-spin"></i> |
|||
<a href="." >Upgrading from v4 to v5</a> |
|||
</h1> |
|||
</div> |
|||
|
|||
|
|||
|
|||
|
|||
<div class="page-wrapper" tabindex="-1" role="main"> |
|||
<div class="page-inner"> |
|||
|
|||
<div id="book-search-results"> |
|||
<div class="search-noresults"> |
|||
|
|||
<section class="normal markdown-section"> |
|||
|
|||
<h1 id="upgrading-from-neutrino-v4-to-v5">Upgrading from Neutrino v4 to v5</h1> |
|||
<p>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:</p> |
|||
<ul> |
|||
<li>Updates to config for creating plugins (from webpack-chain v3 upgrade):</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// Creating plugins in v4</span> |
|||
neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">plugin</span><span class="token punctuation">(</span>name<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>WebpackPlugin<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>args<span class="token punctuation">)</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// Creating plugins in v5</span> |
|||
neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">plugin</span><span class="token punctuation">(</span>name<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>WebpackPlugin<span class="token punctuation">,</span> args<span class="token punctuation">)</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>Updates to config for modifying plugins (from webpack-chain v3 upgrade):</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// Modifying plugins in v4</span> |
|||
neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">plugin</span><span class="token punctuation">(</span>name<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">inject</span><span class="token punctuation">(</span><span class="token punctuation">(</span>Plugin<span class="token punctuation">,</span> args<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token keyword">new</span> <span class="token class-name">Plugin</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>newArgs<span class="token punctuation">)</span><span class="token punctuation">)</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// Modifying plugins in v5</span> |
|||
neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">plugin</span><span class="token punctuation">(</span>name<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">tap</span><span class="token punctuation">(</span>args <span class="token operator">=</span><span class="token operator">></span> newArgs<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>Updates to config for creating loaders (from webpack-chain v3 upgrade):</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// Creating loaders in v4</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'compile'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">'babel'</span><span class="token punctuation">,</span> <span class="token string">'babel-loader'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> |
|||
options<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
plugins<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'object-rest-spread'</span><span class="token punctuation">]</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// Creating loaders in v5</span> |
|||
neutrino<span class="token punctuation">.</span>config |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'compile'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token string">'babel'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">'babel-loader'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">options</span><span class="token punctuation">(</span><span class="token punctuation">{</span> plugins<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'object-rest-spread'</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>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:</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// Modifying loaders in v4</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'compile'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">'babel'</span><span class="token punctuation">,</span> props <span class="token operator">=</span><span class="token operator">></span> <span class="token function">merge</span><span class="token punctuation">(</span>props<span class="token punctuation">,</span> <span class="token punctuation">{</span> |
|||
options<span class="token punctuation">:</span> <span class="token punctuation">{</span> |
|||
plugins<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'object-rest-spread'</span><span class="token punctuation">]</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// Modifying loaders in v5</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'compile'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token string">'babel'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">tap</span><span class="token punctuation">(</span>options <span class="token operator">=</span><span class="token operator">></span> <span class="token function">merge</span><span class="token punctuation">(</span>options<span class="token punctuation">,</span> <span class="token punctuation">{</span> plugins<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'object-rest-spread'</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>Updates to <code>include</code> and <code>exclude</code> for rules (from webpack-chain v3). In the previous webpack-chain |
|||
package, <code>include</code> and <code>exclude</code> were functions where you provided paths as arguments. These are now |
|||
<code>ChainedMap</code>s, making them much more extensible should you need to manipulate these values:</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// Adding rule includes and excludes in v4</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'compile'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">include</span><span class="token punctuation">(</span>x<span class="token punctuation">,</span> y<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">exclude</span><span class="token punctuation">(</span>x<span class="token punctuation">,</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// Adding rule includes and excludes in v5</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'compile'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span>include |
|||
<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>y<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span>exclude |
|||
<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>y<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// You can also use .merge() to add multiple paths at once:</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'compile'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span>include<span class="token punctuation">.</span><span class="token function">merge</span><span class="token punctuation">(</span><span class="token punctuation">[</span>x<span class="token punctuation">,</span> y<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span>exclude<span class="token punctuation">.</span><span class="token function">merge</span><span class="token punctuation">(</span><span class="token punctuation">[</span>x<span class="token punctuation">,</span> y<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>Simple configuration via package.json now done from top-level <code>neutrino</code> object. Rename <code>config</code> to <code>neutrino</code>, and |
|||
rename <code>config.neutrino</code> to <code>neutrino.config</code>. Presets also fall under this <code>neutrino</code> object. The <code>custom</code> object has |
|||
been renamed to <code>options</code>.</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span> |
|||
<span class="token property">"neutrino"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"config"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"entry"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"vendor"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"react"</span><span class="token punctuation">]</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">,</span> |
|||
<span class="token property">"presets"</span><span class="token operator">:</span> <span class="token punctuation">[</span> |
|||
<span class="token string">"neutrino-preset-react"</span> |
|||
<span class="token punctuation">]</span><span class="token punctuation">,</span> |
|||
<span class="token property">"options"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"mocha"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"reporter"</span><span class="token operator">:</span> <span class="token string">"nyan"</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>The Web preset has renamed its styling rule from <code>css</code> to <code>style</code>:</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// v4 API for Web preset</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'css'</span><span class="token punctuation">)</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// v5 API for Web preset</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'style'</span><span class="token punctuation">)</span> |
|||
</code></pre> |
|||
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span> |
|||
<span class="token property">"neutrino"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"config"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"module"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"rule"</span><span class="token operator">:</span> <span class="token punctuation">{</span> |
|||
<span class="token property">"style"</span><span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>Jest upgraded to v19, which changes the option <code>testPathDirs</code> to <code>roots</code>. Jest options set using |
|||
package.json can now only be done at <code>neutrino.options.jest</code> (no more package.json <code>jest</code>);</li> |
|||
<li>Linting base is deprecated in favor of <code>neutrino-middleware-eslint</code>:</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// v4 API</span> |
|||
<span class="token keyword">const</span> lint <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino-lint-base'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token function">lint</span><span class="token punctuation">(</span>neutrino<span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
neutrino<span class="token punctuation">.</span>config<span class="token punctuation">.</span>module |
|||
<span class="token punctuation">.</span><span class="token function">rule</span><span class="token punctuation">(</span><span class="token string">'lint'</span><span class="token punctuation">)</span> |
|||
<span class="token punctuation">.</span><span class="token function">loader</span><span class="token punctuation">(</span><span class="token string">'eslint'</span><span class="token punctuation">,</span> props <span class="token operator">=</span><span class="token operator">></span> <span class="token function">merge</span><span class="token punctuation">(</span>props<span class="token punctuation">,</span> <span class="token punctuation">{</span> rules<span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token comment" spellcheck="true">/* */</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// v5 API</span> |
|||
<span class="token keyword">const</span> eslint <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino-middleware-eslint'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
neutrino<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>eslint<span class="token punctuation">,</span> <span class="token punctuation">{</span> |
|||
rules<span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token comment" spellcheck="true">/* */</span> <span class="token punctuation">}</span> |
|||
<span class="token punctuation">}</span><span class="token punctuation">)</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>When using a linting preset or consuming anything with <code>neutrino-middleware-eslint</code>, the <code>eslintrc()</code> method has been |
|||
moved from <code>neutrino.custom.eslintrc</code> to <code>neutrino.eslintrc</code>:</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// v4 API</span> |
|||
neutrino<span class="token punctuation">.</span>custom<span class="token punctuation">.</span><span class="token function">eslintrc</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// v5 API</span> |
|||
neutrino<span class="token punctuation">.</span><span class="token function">eslintrc</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>The Neutrino API no longer accepts preset strings in its constructor. The constructor now accepts an options object to |
|||
be set at <code>neutrino.options</code>:</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token keyword">const</span> Neutrino <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> api <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Neutrino</span><span class="token punctuation">(</span><span class="token punctuation">{</span> mocha<span class="token punctuation">:</span> <span class="token punctuation">{</span> reporter<span class="token punctuation">:</span> <span class="token string">'nyan'</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
api<span class="token punctuation">.</span>options<span class="token punctuation">.</span>mocha<span class="token punctuation">.</span>reporter <span class="token comment" spellcheck="true">// "nyan"</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li>Since the Neutrino API no longer accepts preset strings in its constructor, you must now pass presets and middleware |
|||
as code/functions to the <code>.use()</code> method. This means the API no longer does preset module resolution. This has been |
|||
moved to the CLI.</li> |
|||
</ul> |
|||
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// v4 API</span> |
|||
<span class="token keyword">const</span> Neutrino <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> api <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Neutrino</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'neutrino-preset-node'</span><span class="token punctuation">,</span> <span class="token string">'neutrino-preset-mocha'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
<span class="token comment" spellcheck="true">// v5 API</span> |
|||
<span class="token keyword">const</span> Neutrino <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
<span class="token keyword">const</span> api <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Neutrino</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
|
|||
api<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino-preset-node'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
api<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'neutrino.preset-mocha'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> |
|||
</code></pre> |
|||
<ul> |
|||
<li><code>neutrino.getWebpackOptions()</code> no longer caches the configuration after being called.</li> |
|||
<li>Using a <code>node</code> target no longer skips the watcher for a builder, it now uses the Webpack source watcher. This means |
|||
commands like <code>neutrino start && node build</code> is obsolete. <code>neutrino build && node build</code> would work to start a Node |
|||
instance for production-built bundles.</li> |
|||
</ul> |
|||
|
|||
|
|||
</section> |
|||
|
|||
</div> |
|||
<div class="search-results"> |
|||
<div class="has-results"> |
|||
|
|||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1> |
|||
<ul class="search-results-list"></ul> |
|||
|
|||
</div> |
|||
<div class="no-results"> |
|||
|
|||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
|
|||
|
|||
<a href="cli/" class="navigation navigation-prev navigation-unique" aria-label="Previous page: CLI"> |
|||
<i class="fa fa-angle-left"></i> |
|||
</a> |
|||
|
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
<script> |
|||
var gitbook = gitbook || []; |
|||
gitbook.push(function() { |
|||
gitbook.page.hasChanged({"page":{"title":"Upgrading from v4 to v5","level":"1.13","depth":1,"next":{"title":"v4 Documentation","level":"1.14","depth":1,"url":"https://github.com/mozilla-neutrino/neutrino-dev/tree/docs-v4/docs","ref":"https://github.com/mozilla-neutrino/neutrino-dev/tree/docs-v4/docs","articles":[]},"previous":{"title":"CLI","level":"1.12","depth":1,"path":"cli/README.md","ref":"./cli/README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","prism","-highlight","github","anchorjs","npmsearchlist"],"root":"./docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/mozilla-neutrino/neutrino-dev/"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"npmsearchlist":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit page","base":"https://github.com/mozilla-neutrino/neutrino-dev/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchorjs":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Neutrino","gitbook":"*"},"file":{"path":"upgrading-neutrino.md","mtime":"2017-03-15T13:20:51.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-03-15T14:46:02.288Z"},"basePath":".","book":{"language":""}}); |
|||
}); |
|||
</script> |
|||
</div> |
|||
|
|||
|
|||
<script src="gitbook/gitbook.js"></script> |
|||
<script src="gitbook/theme.js"></script> |
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-edit-link/plugin.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-github/plugin.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/3.1.1/anchor.min.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-anchorjs/anchor-style.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-npmsearchlist/script.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-search/search.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script> |
|||
|
|||
|
|||
|
|||
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script> |
|||
|
|||
|
|||
|
|||
</body> |
|||
</html> |
|||
|
Loading…
Reference in new issue