aurelia / cli

The Aurelia 1 command line tool. Use the CLI to create projects, scaffold components, and bundle your app for release.
MIT License
407 stars 133 forks source link

.Net Core 2.0 + Webpack fails out of the box #786

Closed mttmccb closed 6 years ago

mttmccb commented 6 years ago

I'm submitting a bug report

Current behavior: Following installation the app fails to load (see the loading screen and that's it) after dotnet run with a 404 on http://localhost:5000/dist/vendor.css

The following options were chosen

What is the expected behavior? App runs successfully

What is the motivation / use case for changing the behavior? I want it to work out of the box

grufffta commented 6 years ago

I think you are seeing the loading screen as you have not set the environment variable ASPNETCORE_ENVIRONMENT=Development It should load, the missing vendor.css should just be a warning in the console and you can probably remove it from the _ViewLayout as the CSS is injected into the page automatically.

mttmccb commented 6 years ago

I'll have a look (not in the office few a days) but I would still expect it to work regardless of the environment, I haven't looked into the config but I'm guessing it will minify/hash the files?

JeroenVinke commented 6 years ago

If it turns out not to be the problem try to downgrade nodejs. 9.1 is pretty new

grufffta commented 6 years ago

@mttmccb the variable is required as the webpack dev middleware is only enabled in development environments within the startup project file. See here for more info: https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/

If you do dotnet publish it will produce production minified files. When you have generated the files with either dotnet publish (or au build) you could run without the environment variable set but you wouldn't have HMR

mttmccb commented 6 years ago

Thanks, I can confirm for development the following worked

export ASPNETCORE_ENVIRONMENT=Development
dotnet run

and for production

export ASPNETCORE_ENVIRONMENT=Production
dotnet publish
dotnet run

It did throw a few errors for production but still worked ok.

/usr/local/share/dotnet/sdk/2.0.0/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Publish.targets(109,5): error MSB3030: Could not copy the file "/Users/matt/test/POC.AureliaWebpackCLI/wwwroot/dist/app.bundle.js" because it was not found. [/Users/matt/test/POC.AureliaWebpackCLI/project.csproj]
/usr/local/share/dotnet/sdk/2.0.0/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Publish.targets(109,5): error MSB3030: Could not copy the file "/Users/matt/test/POC.AureliaWebpackCLI/wwwroot/dist/vendor.bundle.js" because it was not found. [/Users/matt/test/POC.AureliaWebpackCLI/project.csproj]

Where would the best place to document this? As part of the wizard or maybe just in the CLI docs?

JeroenVinke commented 6 years ago

Thanks for the update @mttmccb

We can link to the microsoft docs in the wizard and in the cli docs

JeroenVinke commented 6 years ago

added this to https://github.com/aurelia/cli/pull/747