Skip to content
This repository was archived by the owner on Mar 22, 2019. It is now read-only.

usage with grunt.cn

e-cloud edited this page Mar 19, 2016 · 1 revision

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

有个grunt的插件使用了webpack和webpack-dev-server: grunt-webpack

It's pretty simple to use:

使用非常简单:

module.exports = function(grunt) {
	grunt.loadNpmTasks("grunt-webpack");
	grunt.initConfig({
		webpack: {
			options: {
				// configuration for all builds
			},
			build: {
				// configuration for this build
			}
		},
		"webpack-dev-server": {
			options: {
				webpack: {
					// configuration for all builds
				},
				// server and middleware options for all builds
			},
			start: {
				webpack: {
					// configuration for this build
				},
				// server and middleware options for this build
			}
		}
	});
};

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.

开发的最佳选项是使用webpack-dev-server,但它需要部署一个服务器。如果这不太可能或者对于普通的构建过于复杂,监视迭代也是可以的。

Example

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

看一下gruntfile样例,其囊括三种模式:

  • webpack-dev-server

  • build - watch cycle

  • production build

  • webpack-dev-server

  • 构建-监视 迭代

  • 发布的构建

Gruntfile样例

Clone this wiki locally