node package manager

neutrino

Create and build JS applications with managed configurations

Create and build modern JavaScript applications with zero initial configuration and minimal fuss.


Neutrino is a helper tool which lets you build web and Node.js applications with shared configurations. It intends to make the process of initializing and building projects much simpler by providing minimal development dependencies. Neutrino uses Webpack to build both web and Node.js projects by providing complete build presets which can be shared across targets and projects. You can use neutrino base presets to get started building a variety of projects, create your own presets by extending the neutrino code presets to be shared across your own projects or even by the community. Presets can even be manipulated on a project-by-project basis to handle almost any build situation your preset doesn't cover.


  • Preset-based Webpack building with development and production support
  • Test web projects with Karma + Mocha, and Node.js projects with Mocha
  • Web: Build modern, generic web applications
  • Node.js: Build modern Node.js applications
  • React: Build React-based web applications
  • v3 (latest): Node.js v4+ and yarn
  • v2: Node.js v4+ and npm

Neutrino projects require 2 development dependencies: neutrino itself and a build configuration preset. Neutrino provides core presets for building generic web applications, Node.js, or React applications. If these presets do not meet your needs, feel free to use a community-provided preset or extend one of these presets to meet your needs.

To get started using neutrino in your project, install neutrino and your preset as development dependencies. In this example, we want to build a React application:

npm install --save-dev neutrino neutrino-preset-react

With neutrino and your preset in place, modify the scripts in your package.json to use neutrino for building the project:

{
  "scripts": {
    "start": "PORT=3000 neutrino start --preset neutrino-preset-react",
    "test": "neutrino test --preset neutrino-preset-react",
    "build": "neutrino build --preset neutrino-preset-react"
  }
}

By default, neutrino preset look for source code in src/, and tests in test/. Use your npm scripts to start building!

# Build the application in development mode 
yarn start
 
# Build the application and run any tests 
yarn test
 
# Build the application in production mode, outputting content to build/ 
yarn run build

If you plan to use the same preset across all your script targets, you can add a config entry to your package.json to specify this:

{
  "config": {
    "preset": "neutrino-preset-react"
  },
  "scripts": {
    "start": "PORT=3000 neutrino start",
    "test": "neutrino test",
    "build": "neutrino build"
  }
}

Neutrino core presets provide a good baseline for developing a few different types of JavaScript applications by providing configuration for Webpack, ESLint, Karma, and Mocha. If you need to modify preset configuration, you can require the preset in your project and specify a new preset to neutrino with the changes.

For example, let's say you have a project using the neutrino web preset, but now want to support building LESS files. Let's create a new custom preset in your project to handle this, e.g. custom-preset.js:

// require the preset to change 
const preset = require('neutrino-preset-web');
// also a using helper to deep-copy an object 
const clone = require('lodash.clonedeep');
 
// Find the preset's CSS loader 
const cssLoader = preset.module.loaders.find(l => /css/.test(l.test));
 
// Make a copy of the loader so we can use it for LESS loading, while still keeping normal 
// CSS loading 
const lessLoader = clone(cssLoader);
 
// Change the files the loader uses to .less files 
lessLoader.test = /\.less$/;
 
// Add the less-loader to this loader which handles LESS compilation 
lessLoader.loaders.push(require.resolve('less-loader'));
 
// Add the new LESS loader to the preset 
preset.module.loaders.push(lessLoader);
 
// re-export the modified preset 
module.exports = preset;

Now use your new preset in your package.json scripts:

{
  "scripts": {
    "start": "neutrino start -p custom-preset.js"
  }
}

Creating shareable presets

Creating neutrino presets uses the same premise as modifying a preset, but with the addition that these can be published to npm and used in numerous projects. See the neutrino core presets for examples on how this is accomplished for tips on creating your own presets.

If you are having issues, please let us know.

This project is licensed under the Mozilla Public License v2.0