Skip to content

numindsoftware/VueCliSpaExtensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Build status NuGet Badge numind-aspnetcore MyGet Build Status

A Vue-Cli support for AspNetCore SPAs

Allows use of vue-cli-service in ASPNetCore Spa Applications by supporting a development experience similar to both UseReactDevelopmentServer & UseAngularCliServer. See: https://www.nuget.org/packages/Microsoft.AspNetCore.SpaServices.Extensions/ This library supports both NPM and Yarn package managers.

Usage

The ASPNET Core framework has support for a new setup when creating SPA pplications, using the default templates generated code which uses the new Microsoft.AspNetCore.SpaServices.Extensions package. Both React and Angular development setups are supported, the code in Startup.cs looks somewhat like this:

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            ...
            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    // Angular
                    spa.UseAngularCliServer(npmScript: "start");
                    ...
                    // react
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });
        }

This package adds a new extension method UseVueCliDevelopmentServer and support for Yarn Package Manager by way of a new parameter which default to NPM.

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            ...
            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseVueCliDevelopmentServer(npmScript: "start", packageManager: PackageManager.Yarn);
                }
            });
        }

UseVueCliDevelopmentServer will call the run command (ex: yarn run start) of the specified package manager in packageManager: argument.

Your package.json script section should look like the following in order for the vue-cli development server to launch:

  "scripts": {
    "start": "vue-cli-service serve",
    ...
  }

License

https://www.apache.org/licenses/LICENSE-2.0

About

VueCli support for SpaServices.Extensions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published