aspnet / JavaScriptServices

[Archived] This repository has been archived
Apache License 2.0
3.03k stars 518 forks source link

React SPA Template site.css 404 #839

Closed firewave-remo closed 7 years ago

firewave-remo commented 7 years ago

Somewhere in the configuration there is a wrong setting.

When you create a clean new react project with Yeoman or with dotnet new react and then running the applicaton you will get a 404 for the site.css File.

In the reactredux template everything is ok.

SteveSandersonMS commented 7 years ago

If you check your _Layout.cshtml file, you'll see that the React template only references site.css when it's in staging or production modes:

    <environment names="Staging,Production">
        <link rel="stylesheet" href="~/dist/site.css" asp-append-version="true" />
    </environment>

To run your app locally in development (without first running Webpack to produce a production build), you must have the app in development mode, otherwise various things don't work. Not sure if you were following a tutorial or something, but please have a look at this post and its Option 1: Running via the Command Line, or for more general info, see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments