@constgen/neutrino-mode
Neutrino middleware to automatically choose the building mode (production or development) based on CLI command. It allows to pass less flags when run webpack
or webpack-dev-server
Requirements
Installation
@constgen/neutrino-mode
can be installed from NPM. You should install it to "dependencies"
(--save) or "devDependncies"
(--save-dev) depending on your goal.
npm install --save @constgen/neutrino-mode
Usage
Important: If you use this middleware, you should use it at the very beginning before any other middlewares as it correctly defines process.env.NODE_ENV
and neutrino.config.mode()
These commands will enable development mode and watching. So it is recommended to use one of them in package.json scripts.start
:
webpack-dev-server
webpack --mode development
All other commands will be production. So it is recommended to use one of them in package.json scripts.build
:
webpack
webpack --mode production
In preset
Require this package and plug it into Neutrino. The middleware has no options:
let mode = require('@constgen/neutrino-mode')
neutrino.use(mode())
In neutrinorc
The middleware also may be used together with another presets in Neutrino rc-file, e.g.:
.neutrinorc.js
let mode = require('@constgen/neutrino-mode')
module.exports = {
use: [
mode()
]
}