Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webpack-contrib/grunt-webpack
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.1.3
Choose a base ref
...
head repository: webpack-contrib/grunt-webpack
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.0
Choose a head ref

Commits on Sep 2, 2018

  1. docs: Remove outdated notice

    danez authored Sep 2, 2018
    Copy the full SHA
    c494175 View commit details
  2. chore: Update dependencies

    danez committed Sep 2, 2018
    Copy the full SHA
    11b9b9a View commit details

Commits on Feb 14, 2019

  1. fix: Read raw config in tasks to avoid circular dependency

    BREAKING CHANGE: Grunt templates will not be evaluated in Plugins anymore. Use lazy config loading instead.
    danez committed Feb 14, 2019
    Copy the full SHA
    570f378 View commit details
  2. Copy the full SHA
    e2cf0cd View commit details
  3. Update README

    danez committed Feb 14, 2019
    Copy the full SHA
    9a4e03e View commit details
  4. chore: Update dependencies

    danez committed Feb 14, 2019
    Copy the full SHA
    9ea9367 View commit details
  5. fix: Update lodash

    danez committed Feb 14, 2019
    Copy the full SHA
    5836231 View commit details
  6. fix: Drop support for node < 6.11.5 and webpack < 4

    BREAKING CHANGE: Ensure you are using node 6.11.5 or newer and webpack 4
    danez committed Feb 14, 2019
    Copy the full SHA
    36aba57 View commit details
  7. chore: Use prettier

    danez committed Feb 14, 2019
    Copy the full SHA
    ff0475e View commit details

Commits on Jul 12, 2019

  1. chore(deps): bump lodash.template from 4.4.0 to 4.5.0 (#174)

    Bumps [lodash.template](https://github.com/lodash/lodash) from 4.4.0 to 4.5.0.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](lodash/lodash@4.4.0...4.5.0)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and danez committed Jul 12, 2019
    Copy the full SHA
    1fc9c88 View commit details
  2. chore(deps): bump lodash.merge from 4.6.1 to 4.6.2 (#173)

    Bumps [lodash.merge](https://github.com/lodash/lodash) from 4.6.1 to 4.6.2.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](https://github.com/lodash/lodash/commits)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and danez committed Jul 12, 2019
    Copy the full SHA
    b79a244 View commit details
  3. Copy the full SHA
    b846f09 View commit details

Commits on Aug 27, 2019

  1. chore(deps): bump eslint-utils from 1.3.1 to 1.4.2 (#177)

    Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.3.1 to 1.4.2.
    - [Release notes](https://github.com/mysticatea/eslint-utils/releases)
    - [Commits](mysticatea/eslint-utils@v1.3.1...v1.4.2)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and danez committed Aug 27, 2019
    Copy the full SHA
    68c6bf6 View commit details

Commits on Apr 5, 2020

  1. chore(deps): bump acorn from 6.2.0 to 6.4.1 (#180)

    Bumps [acorn](https://github.com/acornjs/acorn) from 6.2.0 to 6.4.1.
    - [Release notes](https://github.com/acornjs/acorn/releases)
    - [Commits](acornjs/acorn@6.2.0...6.4.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Apr 5, 2020
    Copy the full SHA
    2d5b66f View commit details
  2. chore(deps): bump handlebars from 4.1.2 to 4.5.3 (#179)

    Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
    - [Release notes](https://github.com/wycats/handlebars.js/releases)
    - [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
    - [Commits](handlebars-lang/handlebars.js@v4.1.2...v4.5.3)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Apr 5, 2020
    Copy the full SHA
    85e991c View commit details

Commits on Jul 20, 2020

  1. chore(deps): bump lodash from 4.17.14 to 4.17.19

    Bumps [lodash](https://github.com/lodash/lodash) from 4.17.14 to 4.17.19.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](lodash/lodash@4.17.14...4.17.19)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and danez committed Jul 20, 2020
    Copy the full SHA
    31e99f3 View commit details
  2. fix: remove adding of HMR plugin, since addDevServerEntrypoints alrea…

    …dy does it
    
    BREAKING CHANGE: Requires webpack-dev-server 3.2.0 or newer
    steinm91 authored and danez committed Jul 20, 2020
    Copy the full SHA
    4b2fbf8 View commit details
  3. chore: Require node 10

    BREAKING CHANGE: Ensure you use node 10.13.0 or newer before upgrading to this grunt-webpack version
    danez committed Jul 20, 2020
    Copy the full SHA
    3b218ab View commit details
  4. Copy the full SHA
    d4b1bac View commit details
  5. Copy the full SHA
    1cd0741 View commit details
  6. chore: Migrate to jest

    danez committed Jul 20, 2020
    Copy the full SHA
    ee287ce View commit details
  7. Copy the full SHA
    e40dbe9 View commit details
  8. feat: Add support for webpack 5

    danez committed Jul 20, 2020
    Copy the full SHA
    920c6d9 View commit details
  9. chore: Add semantic release

    danez committed Jul 20, 2020
    Copy the full SHA
    671d5b8 View commit details
  10. fix(deps): Upgrade dependencies

    danez committed Jul 20, 2020
    Copy the full SHA
    f6ca1c3 View commit details
Showing with 7,569 additions and 3,842 deletions.
  1. +0 −40 .eslintrc
  2. +23 −0 .eslintrc.json
  3. +1 −1 .gitignore
  4. +1 −0 .prettierignore
  5. +3 −0 .prettierrc
  6. +20 −21 .travis.yml
  7. +98 −20 README.md
  8. +5 −0 babel.config.js
  9. +23 −33 package.json
  10. +21 −53 src/options/OptionHelper.js
  11. +9 −5 src/options/WebpackDevServerOptionHelper.js
  12. +5 −5 src/options/WebpackOptionHelper.js
  13. +56 −0 src/options/__tests__/WebpackOptionHelper.test.js
  14. +55 −0 src/options/__tests__/default.test.js
  15. +26 −11 src/options/default.js
  16. +11 −15 src/plugins/CachePluginFactory.js
  17. +4 −4 src/plugins/ProgressPluginFactory.js
  18. +111 −69 tasks/webpack-dev-server.js
  19. +49 −31 tasks/webpack.js
  20. +0 −94 tests/fixtures.js
  21. +0 −10 tests/fixtures/webpack/banner-plugin-webpack-4/exec.js
  22. +0 −10 tests/fixtures/webpack/basic/exec.js
  23. +0 −27 tests/fixtures/webpack/circular-reference-in-options/Gruntfile.js
  24. +0 −4 tests/fixtures/webpack/error-without-stats/exec.js
  25. +0 −4 tests/fixtures/webpack/error/exec.js
  26. +0 −18 tests/fixtures/webpack/loader-path/webpack.config.js
  27. +0 −3 tests/fixtures/webpack/no-config/exec.js
  28. +107 −0 tests/integration/fixtures.test.js
  29. 0 tests/{ → integration}/fixtures/.gitignore
  30. +9 −6 tests/{ → integration}/fixtures/webpack/banner-plugin-webpack-4/Gruntfile.js
  31. 0 tests/{ → integration}/fixtures/webpack/banner-plugin-webpack-4/entry.js
  32. +9 −0 tests/integration/fixtures/webpack/banner-plugin-webpack-4/exec.js
  33. +2 −1 tests/{ → integration}/fixtures/webpack/basic/Gruntfile.js
  34. 0 tests/{ → integration}/fixtures/webpack/basic/entry.js
  35. +10 −0 tests/integration/fixtures/webpack/basic/exec.js
  36. +2 −1 tests/{ → integration}/fixtures/webpack/cache/Gruntfile.js
  37. 0 tests/{ → integration}/fixtures/webpack/cache/entry.js
  38. +1 −1 tests/{ → integration}/fixtures/webpack/cache/exec.js
  39. +24 −0 tests/integration/fixtures/webpack/circular-reference-in-plugin-options/Gruntfile.js
  40. 0 ...eference-in-options → integration/fixtures/webpack/circular-reference-in-plugin-options}/entry.js
  41. 0 ...reference-in-options → integration/fixtures/webpack/circular-reference-in-plugin-options}/exec.js
  42. +5 −1 tests/{ → integration}/fixtures/webpack/error-without-stats/Gruntfile.js
  43. 0 tests/{ → integration}/fixtures/webpack/error-without-stats/entry.js
  44. +4 −0 tests/integration/fixtures/webpack/error-without-stats/exec.js
  45. +5 −1 tests/{ → integration}/fixtures/webpack/error/Gruntfile.js
  46. 0 tests/{ → integration}/fixtures/webpack/error/entry.js
  47. +4 −0 tests/integration/fixtures/webpack/error/exec.js
  48. +1 −1 tests/{ → integration}/fixtures/webpack/loader-path/Gruntfile.js
  49. 0 tests/{ → integration}/fixtures/webpack/loader-path/exec.js
  50. 0 tests/{ → integration}/fixtures/webpack/loader-path/main.js
  51. +18 −0 tests/integration/fixtures/webpack/loader-path/webpack.config.js
  52. +7 −7 tests/{ → integration}/fixtures/webpack/multi-compiler-verbose/Gruntfile.js
  53. 0 tests/{ → integration}/fixtures/webpack/multi-compiler-verbose/entry.js
  54. 0 tests/{ → integration}/fixtures/webpack/multi-compiler-verbose/entry2.js
  55. 0 tests/{ → integration}/fixtures/webpack/multi-compiler-verbose/exec.js
  56. 0 tests/{ → integration}/fixtures/webpack/multi-compiler-verbose/options.json
  57. +7 −7 tests/{ → integration}/fixtures/webpack/multi-compiler/Gruntfile.js
  58. 0 tests/{ → integration}/fixtures/webpack/multi-compiler/entry.js
  59. 0 tests/{ → integration}/fixtures/webpack/multi-compiler/entry2.js
  60. 0 tests/{ → integration}/fixtures/webpack/multi-compiler/exec.js
  61. +1 −1 tests/{ → integration}/fixtures/webpack/no-config/Gruntfile.js
  62. 0 tests/{ → integration}/fixtures/webpack/no-config/entry.js
  63. +3 −0 tests/integration/fixtures/webpack/no-config/exec.js
  64. +0 −49 tests/src/options/WebpackOptionHelper.js
  65. +0 −54 tests/src/options/default.js
  66. +5 −7 tests/utils/assertGrunt.js
  67. +6,824 −3,227 yarn.lock
40 changes: 0 additions & 40 deletions .eslintrc

This file was deleted.

23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": ["eslint:recommended", "webpack", "prettier"],
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "script"
},
"env": {
"node": true
},
"rules": {
"prettier/prettier": "error",
"no-plusplus": "off",
"global-require": "off",
"class-methods-use-this": "off",
"no-param-reassign": "off",
"no-underscore-dangle": "off",
"no-undefined": "off"
},
"overrides": [
{ "files": "**/*.test.js", "parserOptions": { "sourceType": "module" } }
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -2,5 +2,5 @@
coverage
node_modules
npm-debug.log
tests/tmp
tests/integration/tmp
yarn-error.log
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/fixtures/**/*
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "all"
}
41 changes: 20 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
language: node_js
sudo: false
node_js:
- "8"
- "6"
env:
- JOB=test
- "14"
- "12"
- "10"
cache:
yarn: true
directories:
- "node_modules"
matrix:
fast_finish: true
before_script: 'if [[ "$WEBPACK" != "default" ]]; then yarn add --dev webpack@${WEBPACK}; fi'
script: yarn test
env:
- WEBPACK=default
- WEBPACK=^5.0.0-0
jobs:
include:
- node_js: "lts/*"
env: JOB=lint
- node_js: "10"
env: JOB=test-coverage
before_script:
- 'if [[ -n "$TRAVIS_TAG" ]] && [[ "$TRAVIS_JOB_NUMBER" == *.1 ]]; then yarn run create-github-release; fi'
script:
- 'if [ "$JOB" = "lint" ]; then yarn run lint ; fi'
- 'if [ "$JOB" = "test" ]; then yarn run test-only ; fi'
- 'if [ "$JOB" = "test-coverage" ]; then yarn run test-coverage ; fi'
after_success:
- 'if [ "$JOB" = "test-coverage" ]; then bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json ; fi'
- stage: codestyle
node_js: "lts/*"
script: yarn lint
- stage: release
node_js: lts/*
# Advanced: optionally overwrite your default `script` step to skip the tests
script: skip
deploy:
provider: script
skip_cleanup: true
script: yarn semantic-release
118 changes: 98 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -16,20 +16,14 @@
<p>Use Webpack with Grunt.<p>
</div>

**This is the readme for version 3.0.0. For the 1.0 readme visit [here](https://github.com/webpack-contrib/grunt-webpack/tree/1.0).**

<h2 align="center">Install</h2>

Install 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.

```bash
yarn add webpack grunt-webpack --dev
```

You can still use npm

```bash
npm i webpack grunt-webpack --save-dev
// or
// npm i webpack grunt-webpack --save-dev
```

If you also want to use the webpack-dev-server task you also need to install `webpack-dev-server`
@@ -41,15 +35,15 @@ yarn add webpack-dev-server --dev
Then add this line to your project's `Gruntfile.js` gruntfile:

```javascript
const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
grunt.initConfig({
...,
webpack: {
myConfig: {
// your webpack config
},
myConfig: webpackConfig,
},
...
});
@@ -123,11 +117,13 @@ The webpack-dev-server options [`host`][5], [`hotOnly`][6], [`inline`][1], [`por

### Webpack

#### imported config

This is a simple example that requires the webpack config from the config file.
It also disables stats in non 'development' environments and enables watch in development.

``` javascript
const webpackConfig = require('./webpack.config');
const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {
grunt.initConfig({
@@ -161,25 +157,107 @@ On the command line you can then do the following.

> For more examples and information have a look at the [webpack documentation][9] which mostly also applies here besides the noted differences above.
#### Lazy config loading

In 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).

```js
const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {
grunt.initConfig({
webpack: {
myconfig: () => ({
entry: path.join(__dirname, "entry"),
output: {
path: __dirname,
filename: "output.js",
},
}),
},
});

grunt.loadNpmTasks('grunt-webpack');
};
```

#### Grunt templates

grunt-webpack supports grunt templates in all string values in it's configuration.

In the next example we use a template for `output.filename`.

```js
const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {
grunt.initConfig({
outputFileName: "output.js",
webpack: {
myconfig: {
entry: path.join(__dirname, "entry"),
output: {
path: __dirname,
filename: "<%= outputFileName %>",
},
},
},
});

grunt.loadNpmTasks('grunt-webpack');
};
```

For 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:

```js
const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {
grunt.initConfig({
name: "Webpack",
pkg: {
copyright: '<%= name %>',
version: '6.55.345',
},
webpack: {
myconfig: (config) => ({
entry: path.join(__dirname, "entry"),
output: {
path: __dirname,
filename: "output.js",
},
plugins: [
new webpack.BannerPlugin({
banner: `/*! ${config.pkg.copyright} - Version ${config.pkg.version} dated ${grunt.template.today()} */`,
raw: true,
}),
],
}),
},
});

grunt.loadNpmTasks('grunt-webpack');
};
```

<h2 align="center">Troubleshooting</h2>

### Circular reference detected (.plugins)

If you encounter this message it means that one of the plugins which are present in your config have circular references.
This is totally fine for webpack, but sadly grunt cannot handle these.
This is not a bug in the plugin and is totally fine for webpack, but sadly grunt cannot handle these.

To workaround this problem use lazy config loading, by wrapping your config inside a function.

```js
const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {
grunt.initConfig({
webpack: {
myconfig: function() {
return {
plugins: [...]
};
}
}
myconfig: () => webpackConfig,
},
});

grunt.loadNpmTasks('grunt-webpack');
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use strict";

module.exports = {
presets: [['@babel/env', { targets: { node: "current" } }]],
};
56 changes: 23 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -14,59 +14,49 @@
"url": "https://github.com/webpack-contrib/grunt-webpack/issues"
},
"engines": {
"node": ">=4"
"node": ">=10.13.0"
},
"files": [
"src",
"tasks"
],
"peerDependencies": {
"webpack": "^2.0.0 || ^3.0.0 || ^4.0.0"
"webpack": "^4.0.0"
},
"license": "MIT",
"keywords": [
"gruntplugin"
],
"scripts": {
"create-github-release": "conventional-github-releaser -p angular",
"lint": "eslint src tasks",
"prebump": "yarn test",
"release": "standard-version --sign",
"test": "yarn run lint && yarn run test-only",
"test-coverage": "nyc --reporter=json --reporter=text yarn run test-only",
"test-only": "ava"
"test": "jest"
},
"devDependencies": {
"ava": "^0.25.0",
"babel-core": "^6.17.0",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.6.0",
"conventional-github-releaser": "^3.1.2",
"eslint": "^4.2.0",
"fs-extra": "^6.0.1",
"glob": "^7.1.3",
"grunt": "^1.0.3",
"nyc": "^11.0.3",
"standard-version": "^4.4.0",
"@babel/core": "^7.10.5",
"@babel/preset-env": "^7.10.4",
"babel-loader": "^8.1.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-webpack": "^1.2.5",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4",
"fast-glob": "^3.2.4",
"fs-extra": "^9.0.1",
"grunt": "^1.2.1",
"jest": "^26.1.0",
"prettier": "^2.0.5",
"semantic-release": "^17.1.1",
"webpack": "^4.17.1"
},
"dependencies": {
"deep-for-each": "^2.0.2",
"lodash": "^4.7.0"
"deep-for-each": "^3.0.0",
"lodash": "^4.17.19"
},
"ava": {
"files": [
"**/tests/**/*.js",
"!**/utils/**/*",
"!**/fixtures/**/*",
"!**/tmp/**/*"
]
},
"nyc": {
"all": true,
"include": [
"src/",
"tasks/"
"jest": {
"collectCoverageFrom": [
"src/**/*.js",
"tasks/**/*.js"
]
}
}
Loading