Skip to content

Update Readme.md #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra indentation before else, please remove it

{
//...
app.UseWebpackStatic();
}
//...
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
}
```

Expand Down Expand Up @@ -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.

Expand Down