grunt-webpack

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

Grunt plugin to run webpack 5 builds and webpack-dev-server as Grunt tasks. Current stable version is 7.0.1 (Nov 2025). Release cadence is irregular with major versions aligned to webpack major releases. Requires Node.js >=18.19.0 and webpack ^5 as peer dependencies. Unlike bare webpack CLI, it integrates into Grunt's task pipeline with support for watch mode, progress output, error handling options, and storing stats for other Grunt tasks. Notable breaking changes: v7 dropped Node 16 and removed special cache handling; v6 dropped webpack 4 and Node 12/14; v5 dropped Node <12.13.

error Warning: Task "webpack" not found. Use --force to continue.
cause Plugin not loaded in Gruntfile (missing grunt.loadNpmTasks('grunt-webpack')).
fix
Add grunt.loadNpmTasks('grunt-webpack'); after grunt.initConfig.
error Error: Cannot find module 'webpack'
cause webpack not installed or not in node_modules.
fix
Run npm install webpack --save-dev (it's a peer dependency).
error Error: No configuration found for target: myConfig
cause Target name not defined in grunt.initConfig's webpack object.
fix
Ensure grunt.initConfig({ webpack: { myConfig: ... } }) has the target.
breaking Node.js 16 support removed in v7.0.0.
fix Upgrade to Node.js 18.19.0 or higher.
breaking webpack 4 support dropped in v6.0.0.
fix Upgrade to webpack 5.
breaking Special cache configuration handling removed in v7.0.0.
fix Use webpack's native cache configuration directly.
breaking lodash replaced with webpack-merge in v7.0.0.
fix If you relied on lodash being available, install it separately.
deprecated Node.js 12 and 14 support removed in v6.0.0.
fix Upgrade to Node.js 16.13.0+ (now 18+ for v7).
gotcha Grunt process may hang if watch mode is used without keepalive: true.
fix Set keepalive: true in watch mode, or use default (true when watch: true).
npm install grunt-webpack
yarn add grunt-webpack
pnpm add grunt-webpack

Shows how to configure grunt-webpack with two targets (prod and dev) and register the plugin. Assumes a separate webpack.config.js.

// Install: npm install webpack grunt-webpack --save-dev
// Gruntfile.js
const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {
  grunt.initConfig({
    webpack: {
      options: {
        stats: !process.env.NODE_ENV || process.env.NODE_ENV === 'development'
      },
      prod: Object.assign({}, webpackConfig),
      dev: Object.assign({ watch: true }, webpackConfig)
    }
  });

  grunt.loadNpmTasks('grunt-webpack');
  grunt.registerTask('default', ['webpack:dev']);
};