/// <summary> /// Starts a Vue development server and waits before proceeding with any request for the server to be started /// Once started, redirects "/" requests to the Vue development server root URL. /// This way you can start the ASP.NET Core project in development, which will take care of starting the /// Vue development server. /// /// This feature should only be used in development!r. /// </summary> /// <param name="appBuilder">The <see cref="IApplicationBuilder"/>.</param> /// <param name="sourcePath">The path to the Vue app from the project root. Defaults as "ClientApp"</param> /// <param name="npmScript">The name of the script in your package.json file that launches the Vue app. Defaults as "serve".</param> public static void UseVueDevelopmentServer( this IApplicationBuilder appBuilder, string sourcePath = "ClientApp", string npmScript = "serve") { if (appBuilder == null) { throw new ArgumentNullException(nameof(appBuilder)); } VueDevelopmentServerMiddleware.Attach(appBuilder, sourcePath, npmScript); }
public static void UseVueDevelopmentServer(this ISpaBuilder spaBuilder, string npmScript) { if (spaBuilder == null) { throw new ArgumentNullException(nameof(spaBuilder)); } var spaOptions = spaBuilder.Options; if (string.IsNullOrEmpty(spaOptions.SourcePath)) { throw new InvalidOperationException($"To use {nameof(UseVueDevelopmentServer)}, you must supply a non-empty value for the {nameof(SpaOptions.SourcePath)} property of {nameof(SpaOptions)} when calling {nameof(SpaApplicationBuilderExtensions.UseSpa)}."); } VueDevelopmentServerMiddleware.Attach(spaBuilder, npmScript); }