{"id":36544756,"url":"https://github.com/webpack/grunt-webpack","last_synced_at":"2026-01-12T05:57:42.673Z","repository":{"id":3187097,"uuid":"4219538","full_name":"webpack/grunt-webpack","owner":"webpack","description":"integrate webpack into grunt build process","archived":false,"fork":false,"pushed_at":"2025-12-06T18:05:05.000Z","size":2227,"stargazers_count":266,"open_issues_count":2,"forks_count":71,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-12-22T15:52:26.094Z","etag":null,"topics":["grunt","grunt-webpack","plugin","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"webpack"}},"created_at":"2012-05-03T22:34:46.000Z","updated_at":"2025-12-06T18:05:08.000Z","dependencies_parsed_at":"2024-06-18T12:23:48.479Z","dependency_job_id":"09e05f36-22dd-4df6-9d8a-4384d321d84d","html_url":"https://github.com/webpack/grunt-webpack","commit_stats":{"total_commits":303,"total_committers":39,"mean_commits":7.769230769230769,"dds":0.8085808580858086,"last_synced_commit":"9fe1c93b52f75f871b4b4c851ae9e6bef80ac9de"},"previous_names":["webpack/grunt-webpack"],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/webpack/grunt-webpack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fgrunt-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fgrunt-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fgrunt-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fgrunt-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack","download_url":"https://codeload.github.com/webpack/grunt-webpack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fgrunt-webpack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28335941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grunt","grunt-webpack","plugin","webpack"],"created_at":"2026-01-12T05:57:41.231Z","updated_at":"2026-01-12T05:57:42.661Z","avatar_url":"https://github.com/webpack.png","language":"JavaScript","readme":"[![npm][npm]][npm-url]\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"200\" height=\"200\"\n    src=\"https://cdn.worldvectorlogo.com/logos/grunt.svg\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\" vspace=\"\" hspace=\"25\"\n      src=\"https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eGrunt Webpack\u003c/h1\u003e\n  \u003cp\u003eUse Webpack with Grunt.\u003cp\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eRequirements\u003c/h2\u003e\n\n- Version 6 of `grunt-webpack` supports webpack 5 and (optional) `webpack-dev-server` version 5.\n- Node.js 18.19.0 or newer\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\nInstall this grunt plugin next to your project's [Gruntfile.js](http://gruntjs.com/getting-started). You also need to install webpack yourself, this grunt plugin does not install webpack itself.\n\n```bash\nnpm install webpack grunt-webpack --save-dev\n```\n\nIf you also want to use the webpack-dev-server task you also need to install `webpack-dev-server`\n\n```bash\nnpm install webpack-dev-server --save-dev\n```\n\nThen add this line to your project's `Gruntfile.js` gruntfile:\n\n```javascript\nconst webpackConfig = require('./webpack.config.js');\n\nmodule.exports = function(grunt) {\n\n  // Project configuration.\n  grunt.initConfig({\n    ...,\n    webpack: {\n      myConfig: webpackConfig,\n    },\n    ...\n  });\n\n  grunt.loadNpmTasks('grunt-webpack');\n};\n```\n\n\u003ch2 align=\"center\"\u003eConfiguration\u003c/h2\u003e\n\n`webpack-grunt` offers two different tasks `webpack` and `webpack-dev-server`. Both support all webpack options as\ncan be seen in the [webpack documentation][webpack-config]. For exceptions and additions see this list.\n\n### Both Tasks\n\n#### progress\n\nType: `bool`\nDefault: `true` (`false` if no TTY present)\n\nActivates or deactivates the progress output of webpack.\n\n### Webpack Task\n\n#### failOnError\n\nType: `bool`\nDefault: `true` (`false` if watch mode is used)\n\nWill terminate the grunt process when an error happens if set to `true`. If set to `false` the grunt process will not be immediately terminated on error and instead continue to run.\n\n#### keepalive\n\nType: `bool`\nDefault: `false` (`true` if watch mode is used)\n\nWhen set to true the grunt process/task will be kept alive after webpack task is finished. This is especially useful for `watch` as this usually needs to run as long as not manually killed.\n\n#### storeStatsTo\n\nType: `string`\nDefault: `null`\n\nWhen set the stats from webpack will be written to a variable with the name provided in this option. The variable can later be used inside of other grunt tasks with template tags `\u003c%= %\u003e`.\n\n```js\n...\nstoreStatsTo: \"webpackStats\"\n\n...\n\n\u003c%= webpackStats.hash %\u003e\n...\n```\n\n\u003e For more information about grunt template tags have a look at the [grunt docs][grunt-template].\n\n#### watch\n\nType: `bool`\nDefault: `undefined`\n\n\u003e Turn on watch mode. This means that after the initial build, webpack will continue to watch for changes in any of the resolved files.\n\nTurning on watch mode also sets the following defaults:\n\n- Default `cache` to `true`\n- Default `keepalive` to `true`\n- Default `failOnError` to `false`\n\n### Webpack-dev-server Task\n\nThere are no special options for this task. Some changed defaults for WebpackDevServer options are:\n\n| Name           | default value |\n| -------------- | ------------- |\n| devServer.host | localhost     |\n\n\u003ch2 align=\"center\"\u003eExamples\u003c/h2\u003e\n\n### Webpack\n\n#### imported config\n\nThis is a simple example that requires the webpack config from the config file.\nIt also disables stats in non 'development' environments and enables watch in development.\n\n```javascript\nconst webpackConfig = require(\"./webpack.config.js\");\n\nmodule.exports = function (grunt) {\n  grunt.initConfig({\n    webpack: {\n      options: {\n        stats: !process.env.NODE_ENV || process.env.NODE_ENV === \"development\",\n      },\n      prod: webpackConfig,\n      dev: Object.assign({ watch: true }, webpackConfig),\n    },\n  });\n\n  grunt.loadNpmTasks(\"grunt-webpack\");\n};\n```\n\n\u003e The webpack task in this example has two targets called `prod` and `dev`. They can be renamed to everything besides `options`. See the [grunt docs][grunt-targets] for more information about targets.\n\nOn the command line you can then do the following.\n\n```bash\n# Run webpack with the `prod` target\n\u003e NODE_ENV='production' grunt webpack:prod\n\n# Run webpack with the `dev` target\n\u003e grunt webpack:dev\n\n# Run webpack for all targets\n\u003e grunt webpack\n```\n\n\u003e For more examples and information have a look at the [webpack documentation][webpack-start] which mostly also applies here besides the noted differences above.\n\n#### Lazy config loading\n\nIn some cases you might want to load the webpack config lazy. This can be done by specifying a function as the config value. The first paramter to this function will be the complete grunt config, which can be used in cases where grunt templates do not work (see below).\n\n```js\nmodule.exports = function (grunt) {\n  grunt.initConfig({\n    webpack: {\n      myconfig: () =\u003e ({\n        entry: path.join(__dirname, \"entry\"),\n        output: {\n          path: __dirname,\n          filename: \"output.js\",\n        },\n      }),\n    },\n  });\n\n  grunt.loadNpmTasks(\"grunt-webpack\");\n};\n```\n\nYou could also use a promise\n\n```js\nconst webpackConfig = require(\"./webpack.config.js\");\n\nmodule.exports = function (grunt) {\n  grunt.initConfig({\n    webpack: {\n      myconfig: Promise.resolve(webpackConfig),\n    },\n  });\n\n  grunt.loadNpmTasks(\"grunt-webpack\");\n};\n```\n\n#### Grunt templates\n\ngrunt-webpack supports grunt templates in all string values in it's configuration.\n\nIn the next example we use a template for `output.filename`.\n\n```js\nmodule.exports = function (grunt) {\n  grunt.initConfig({\n    outputFileName: \"output.js\",\n    webpack: {\n      myconfig: {\n        entry: path.join(__dirname, \"entry\"),\n        output: {\n          path: __dirname,\n          filename: \"\u003c%= outputFileName %\u003e\",\n        },\n      },\n    },\n  });\n\n  grunt.loadNpmTasks(\"grunt-webpack\");\n};\n```\n\nFor plugins we cannot support grunt template interpolation, as plugins are class instances which we cannot modify during runtime without breaking them. If you need to use template in a string option to a plugin, you can use lazy config loading and use the supplied config. You can also use grunt inside directly to access utility methods:\n\n```js\nmodule.exports = function (grunt) {\n  grunt.initConfig({\n    name: \"Webpack\",\n    pkg: {\n      copyright: \"\u003c%= name %\u003e\",\n      version: \"6.55.345\",\n    },\n    webpack: {\n      myconfig: (config) =\u003e ({\n        entry: path.join(__dirname, \"entry\"),\n        output: {\n          path: __dirname,\n          filename: \"output.js\",\n        },\n        plugins: [\n          new webpack.BannerPlugin({\n            banner: `/*! ${config.pkg.copyright} - Version ${\n              config.pkg.version\n            } dated ${grunt.template.today()} */`,\n            raw: true,\n          }),\n        ],\n      }),\n    },\n  });\n\n  grunt.loadNpmTasks(\"grunt-webpack\");\n};\n```\n\n### Webpack-dev-server\n\n#### imported config\n\nThis is a simple example that requires the webpack config from the config file. Read how to configure webpack-dev-server in the [webpack-dev-server documentation][webpack-dev-server-config].\n\n```javascript\nconst webpackConfig = require(\"./webpack.config.js\");\n\nmodule.exports = function (grunt) {\n  grunt.initConfig({\n    \"webpack-dev-server\": {\n      dev: webpackConfig,\n    },\n  });\n\n  grunt.loadNpmTasks(\"grunt-webpack\");\n};\n```\n\n\u003e The webpack-dev-server task in this example has one target called `dev`. They can be renamed to everything besides `options`. See the [grunt docs][grunt-targets] for more information about targets.\n\nOn the command line you can then do the following.\n\n```bash\n\n# Run webpack-dev-server with the `dev` target\n\u003e grunt webpack-dev-server:dev\n\n# Run webpack for all possible targets\n\u003e grunt webpack-dev-server\n```\n\n\u003e For more examples and information have a look at the [webpack documentation]5] which mostly also applies here besides the noted differences above.\n\n\u003ch2 align=\"center\"\u003eTroubleshooting\u003c/h2\u003e\n\n### Circular reference detected (.plugins)\n\nIf you encounter this message it means that one of the plugins which are present in your config have circular references.\nThis is not a bug in the plugin and is totally fine for webpack, but sadly grunt cannot handle these.\n\nTo workaround this problem use lazy config loading, by wrapping your config inside a function.\n\n```js\nconst webpackConfig = require(\"./webpack.config.js\");\n\nmodule.exports = function (grunt) {\n  grunt.initConfig({\n    webpack: {\n      myconfig: () =\u003e webpackConfig,\n    },\n  });\n\n  grunt.loadNpmTasks(\"grunt-webpack\");\n};\n```\n\n[grunt-template]: http://gruntjs.com/api/grunt.template\n[webpack-config]: https://webpack.js.org/configuration/\n[webpack-dev-server-config]: https://webpack.js.org/configuration/dev-server/\n[grunt-targets]: https://gruntjs.com/configuring-tasks#task-configuration-and-targets\n[webpack-start]: https://webpack.js.org/guides/get-started/\n[npm]: https://img.shields.io/npm/v/grunt-webpack.svg\n[npm-url]: https://npmjs.com/package/grunt-webpack\n","funding_links":["https://opencollective.com/webpack"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fgrunt-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack%2Fgrunt-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fgrunt-webpack/lists"}