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

aurelia-cli 1.0.0 - .NET Core project with Aurelia built-in bundler does not start #1108

Open nenadvicentic opened 5 years ago

nenadvicentic commented 5 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior:

Bellow are full project options selected:

Global aurelia-cli v1.0.0


| () _ / | | | | / ` | | | | '/ \ | |/ ` | | | | | | | | (| | || | | | / | | (| | | || | | | _,|_,|| _|||_,| __|___|___|

√ Please enter a name for your new project: · WebApplication-Aureli-Cli √ Would you like to use the default setup or customize your choices? · Custom App √ Which bundler would you like to use? · CLI's built-in bundler with an AMD module loader √ Which AMD module loader would you like to use? · RequireJS √ What platform are you targeting? · .NET Core √ What transpiler would you like to use? · TypeScript √ How would you like to setup your HTML template? · Minimum Minification √ What css preprocessor would you like to use? · Sass √ Do you want to add PostCSS processing · Typical √ Which unit test runner would you like to use? · Jest √ Would you like to configure integration testing? · Protractor √ What is your default code editor? · Visual Studio Code √ Which features do you want scaffolded into your project? · Navigation App

Error is: ---> (Inner Exception #0) Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object. (C:\Users\Nenad\AppData\Local\Temp\pd2rae2s.bpj:83:19) at __webpack_require__ (C:\Users\Nenad\AppData\Local\Temp\pd2rae2s.bpj:20:30) at createWebpackDevServer (C:\Users\Nenad\AppData\Local\Temp\pd2rae2s.bpj:62:26) at C:\Users\Nenad\AppData\Local\Temp\1vtizutj.5vx:114:19 at IncomingMessage. (C:\Users\Nenad\AppData\Local\Temp\1vtizutj.5vx:133:38) at IncomingMessage.emit (events.js:194:15) Current directory is: c:\Users\Nenad\source\repos\WebApplication-Aureli-Cli

3cp commented 5 years ago

So there is only instruction on how to hook up webpack. That's probably why old cli didn't have cli-bundler option for dotnet-core app.

I am not a dotnet user, I cannot even got a sample dotnet 2.2 app with aurelia+webpack working, dotnet run still renders old dotnet page, not aurelia app page.

@brandonseydel @artmasa @arjendeblok do you guys knows how to hook up cli-bundler front-end in the Startup.cs? If it's too troublesome, we have to turn off cli-bundler for dotnet-core skeleton.

brandonseydel commented 5 years ago

https://github.com/aurelia/dotnet/blob/master/README.md

You can download the night package and follow the readme to patch an existing cli project. You can also download the templates and start from there.

https://www.nuget.org/packages/Aurelia.DotNet.Templates/

nenadvicentic commented 5 years ago

@3cp I think combination of cli-bundler and dotnet-core project is valid to have, even without tight development integration and hot-module-replacement in place. I am actually using it like this for years.

Bigger problem is that so many project template combinations in aurelia-cli are not setup correctly and do not work from get-go, so new users have no clue what to do.

@brandonseydel I'll take a look at those templates. Thx.

3cp commented 5 years ago

@nenadvicentic if you know how to hook them up, please send a PR :-)

nenadvicentic commented 5 years ago

@3cp I did not manage to connect aurelia-cli with dev middleware myself, but project templates for .NET Core which @brandonseydel suggested above have implementation that works. It uses middleware from aurelia/dotnet:

app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseSpa(spa => {
    spa.Options.SourcePath = "%replaceWithAureliaCLIRoot%";

    if (env.IsDevelopment())
    {
        spa.UseAureliaCliServer(); // Optional HMR (Hot Module Reload)
    }
});
3cp commented 5 years ago

Oh, I didn't know @brandonseydel's solution works for cli-bundler too. We probably should use the middleware in default cli template offering, if someone can create a PR.