disable-output-webpack-plugin
raw JSON → 1.0.1 verified Sat Apr 25 auth: no javascript
Webpack plugin that prevents saving output files to disk, useful for scenarios where you only need webpack's in-memory compilation (e.g., with webpack-dev-server or custom runners). Version 1.0.1 is current, no frequent releases. Simple no-config plugin, lighter than alternatives like `webpack-disk-plugin`. Likely no longer needed with webpack 5's `output.writeToDisk` option.
Common errors
error TypeError: DisableOutputWebpackPlugin is not a constructor ↓
cause Using ES module import syntax (`import DisableOutputWebpackPlugin from ...`) which doesn't resolve to the CommonJS export correctly.
fix
Use
const DisableOutputWebpackPlugin = require('disable-output-webpack-plugin') instead of import. error Module not found: Error: Can't resolve 'disable-output-webpack-plugin' ↓
cause Package not installed or missing from node_modules.
fix
Run
npm install --save-dev disable-output-webpack-plugin. error Error: You forgot to add 'mini-css-extract-plugin' plugin ↓
cause Not related to this plugin; it's a common confusion with other plugins.
fix
Ensure other plugins like MiniCssExtractPlugin are properly configured if used.
Warnings
gotcha The plugin only works with webpack 4 and lower; webpack 5 has native support via `output.writeToDisk: false`. ↓
fix Use webpack 5's built-in `output.writeToDisk: false` instead.
gotcha The constructor accepts no options; passing any argument will be silently ignored. ↓
fix Remove any arguments from `new DisableOutputWebpackPlugin()`.
gotcha If using webpack-dev-server, output is already not written to disk by default, making this plugin redundant. ↓
fix Remove the plugin; webpack-dev-server handles in-memory compilation.
Install
npm install disable-output-webpack-plugin yarn add disable-output-webpack-plugin pnpm add disable-output-webpack-plugin Imports
- DisableOutputWebpackPlugin wrong
import DisableOutputWebpackPlugin from 'disable-output-webpack-plugin'correctconst DisableOutputWebpackPlugin = require('disable-output-webpack-plugin') - default wrong
const { DisableOutputWebpackPlugin } = require('disable-output-webpack-plugin')correctconst DisableOutputWebpackPlugin = require('disable-output-webpack-plugin') - new wrong
new DisableOutputWebpackPlugin({})correctnew DisableOutputWebpackPlugin()
Quickstart
// webpack.config.js
const DisableOutputWebpackPlugin = require('disable-output-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: '/dev/null', // still required but output won't be written
filename: 'bundle.js'
},
plugins: [
new DisableOutputWebpackPlugin()
]
};