From 4c62238048ecff3da32ba6d7df5309016e75e5e6 Mon Sep 17 00:00:00 2001 From: Jason Finch Date: Thu, 29 Mar 2018 13:29:33 +1000 Subject: [PATCH] Update Readme.md Updating code sample to reflect how to Configure. (based on example code) --- README.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3e0dca5..1741d91 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,20 @@ public void ConfigureServices(IServiceCollection services) services.AddWebpack(); } -public void Configure(IApplicationBuilder app) +public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - app.UseWebpack(withDevServer: env.IsDevelopment()); + if (env.IsDevelopment()) + { + //... + app.UseWebpackDevServer(); + } + else + { + //... + app.UseWebpackStatic(); + } + //... app.UseStaticFiles(); - app.UseMvcWithDefaultRoute(); } ``` @@ -84,13 +93,7 @@ Default configuration, that's used in [Quick Start](#quick-start), works the fol The extension can work in two modes: the static mode and the dev server mode. In the static mode it serves the assets from a physical location and in the dev mode it does so from the dev server. Since it provides a single API for obtaining the dev server and the static assets' paths, it can only work in one mode at the same time. -Use `app.UseWebpackStatic()` for the static mode and `app.UseWebpackDevServer()` for the dev server mode in the `Configure` method of your startup class. You can also use a single statement for the both modes - -```csharp -app.UseWebpack(withDevServer: env.IsDevelopment()); -``` - -This will make it work in the dev server mode for the development environment and in the static mode for other environments. +Use `app.UseWebpackStatic()` for the static mode and `app.UseWebpackDevServer()` for the dev server mode in the `Configure` method of your startup class. **Tip**: You can use the static mode for non-webpack static assets, just make sure that the [manifest file format](https://github.com/danethurber/webpack-manifest-plugin#usage) is valid.