webpack-mild-compile

raw JSON →
3.4.0 verified Sat Apr 25 auth: no javascript

A workaround to prevent webpack from endlessly recompiling when files are created or modified during watch mode, particularly useful in combination with plugins that dynamically generate files (e.g., webpack-iconfont, webpack-spritesmith). Version 3.4.0 supports webpack 2/3/4/5. The package provides both a webpack plugin and a Node API to decouple file events and avoid repeated compilation cycles. It is a lightweight, focused solution for a common footgun in webpack development workflows.

error TypeError: webpackMildCompile is not a constructor
cause Trying to use the default export as a constructor for the plugin (e.g., `new require('webpack-mild-compile')()`).
fix
Use the named export Plugin instead: new (require('webpack-mild-compile').Plugin)().
error Cannot find module 'webpack-mild-compile'
cause Package not installed or not in node_modules.
fix
Run npm install --save-dev webpack-mild-compile.
gotcha Plugin must be instantiated with `new Plugin()` — calling the module as a function for plugin usage does nothing.
fix Use `new (require('webpack-mild-compile').Plugin)()` or import the named export.
deprecated No known deprecations in current version.
breaking No known breaking changes between versions.
npm install webpack-mild-compile
yarn add webpack-mild-compile
pnpm add webpack-mild-compile

Shows how to use webpack-mild-compile as a webpack plugin or via Node API to avoid endless recompilation during watch mode.

// Webpack plugin usage (prevent endless recompilation)
const { Plugin } = require('webpack-mild-compile');

// webpack.config.js
module.exports = {
  // ... other config
  plugins: [
    new Plugin()
  ]
};

// Or Node API usage (with webpack and koa-webpack)
const webpack = require('webpack');
const config = require('./webpack.config.js');
const compiler = webpack(config);
require('webpack-mild-compile')(compiler);

const app = new (require('koa'))();
const koaWebpack = require('koa-webpack');
app.use(koaWebpack({ compiler }));