webpack doc

There is a grunt plugin for using webpack and the [[webpack-dev-server]]: grunt-webpack.

It's pretty simple to use:

  1. module.exports = function(grunt) {
  2. grunt.loadNpmTasks("grunt-webpack");
  3. grunt.initConfig({
  4. webpack: {
  5. options: {
  6. // configuration for all builds
  7. },
  8. build: {
  9. // configuration for this build
  10. }
  11. },
  12. "webpack-dev-server": {
  13. options: {
  14. webpack: {
  15. // configuration for all builds
  16. },
  17. // server and middleware options for all builds
  18. },
  19. start: {
  20. webpack: {
  21. // configuration for this build
  22. },
  23. // server and middleware options for this build
  24. }
  25. }
  26. });
  27. };

Development

The best option for development is the [[webpack-dev-server]], but it requires spawning a server. If this is not possible or too complex the normal build - watch cycle is possible too.

Example

Take a look at an example Gruntfile. It covers three modes:

  • webpack-dev-server
  • build - watch cycle
  • production build

Example Gruntfile