Neutrino Clean Middleware
@neutrinojs/clean
is Neutrino middleware for removing or cleaning build
directories.
By default, this plugin will remove all files inside webpack's output.path
directory, as well as all unused webpack assets after every successful rebuild.
Requirements
- Node.js 10+
- Yarn v1.2.1+, or npm v5.4+
- Neutrino 9
- webpack 4
Installation
@neutrinojs/clean
can be installed via the Yarn or npm clients.
Yarn
❯ yarn add --dev @neutrinojs/clean
npm
❯ npm install --save-dev @neutrinojs/clean
Usage
@neutrinojs/clean
can be consumed from the Neutrino API, middleware, or
presets. Require this package and plug it into Neutrino:
const clean = require('@neutrinojs/clean');
neutrino.use(clean());
neutrino.use(
clean({
verbose: neutrino.options.debug,
pluginId: 'clean',
}),
);
const clean = require('@neutrinojs/clean');
module.exports = {
use: [clean()],
};
module.exports = {
use: [
clean({
verbose: neutrino.options.debug,
pluginId: 'clean',
}),
],
};
Additional options can be specified to control the behavior of the underlying
clean-webpack-plugin
. See
CleanWebpackPlugin
's documentation
for available options.
Clean external directories
Pass the dangerouslyAllowCleanPatternsOutsideProject: true
option to remove
directories outside of the project root. This is disabled by default to prevent
deletion of unintended directories.
module.exports = {
use: [
clean({
dangerouslyAllowCleanPatternsOutsideProject: true,
}),
],
};
Customization
@neutrinojs/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:
Name | Description | NODE_ENV |
---|
clean | Removes directories before building. | all |
Contributing
This middleware is part of the
neutrino repository, a monorepo
containing all resources for developing Neutrino and its core presets and
middleware. Follow the
contributing guide for details.
v9.0.0
13 December 2019
Neutrino 9 is our largest release ever, and includes upgrades to
webpack 4, Babel 7 and ESLint 6, along with significant performance
improvements.
The biggest breaking change is the necessity to use external tools
alongside Neutrino, i.e. webpack, ESLint, Jest, Karma, and others'
native CLIs will be used in tandem with Neutrino rather than being used
internally via their APIs. This fixes many bugs, gives more control over
how these tools are run and means usage of new features is no longer
blocked on Neutrino changes to support them.
Please see the migration guide for how to update:
https://neutrinojs.org/migration-guide/#neutrino-v8-to-v9
If you encounter any bugs, have questions or spot improvements that can
be made to the migration guide/docs - we'd love to hear from you:
https://github.com/neutrinojs/neutrino/issues
- Lock file maintenance
#1490
- Update dependency mkdocs-material to v4.6.0
#1502
- Update dependency jscodeshift to ^0.7.0
#1503
- Update dependency mkdocs-material to v4.5.1
#1500
- Update dependency Pygments to v2.5.2
#1499
- Update dependency url-loader to v3
#1498
- Update dependency file-loader to v5
#1496
- Update dependency Pygments to v2.5.1
#1497
- Update dependency ejs to v3
#1495
- Update dependency yargs to v15
#1494
- Update dependency mkdocs-material to v4.5.0
#1493