Created
April 3, 2020 09:53
-
-
Save tgreensill/3640d68efe301c65803e334033cadc94 to your computer and use it in GitHub Desktop.
AspNetCore Spa Service with Vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Wire up MVC and any other dependencies/services | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); | |
// In production, the files will be served from this directory. | |
services.AddSpaStaticFiles(options => options.RootPath = "wwwroot"); | |
} | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
// Wire up middleware... | |
app.UseMvc(routes => | |
{ | |
routes.MapRoute( | |
name: "default", | |
template: "{controller}/{action=Index}/{id?}"); | |
}); | |
app.UseSpa(spa => | |
{ | |
spa.Options.SourcePath = "ClientApp"; | |
if (env.IsDevelopment()) | |
{ | |
// No UseVueDevelopmentServer middleware so hack the react one for now... | |
spa.UseReactDevelopmentServer(npmScript: "serve"); | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
outputDir: './../wwwroot', | |
devServer: { | |
before() { | |
// Output the same message as the react dev server to get the | |
// Asp .Net Spa middleware working with vue. | |
console.info("Starting the development server..."); | |
} | |
} | |
// Add any other configuration options... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment