如何使用Aurelia CLI/ASP.NET Core通过单个项目优化工作流程 [英] How to optimize workflow with single project using Aurelia CLI / ASP.NET Core

查看:64
本文介绍了如何使用Aurelia CLI/ASP.NET Core通过单个项目优化工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET Core项目,该项目还使用TypeScript/SASS托管了一个Aurelia CLI项目. IDE是Visual Studio 2015.

I have an ASP.NET Core project, which also hosts an Aurelia CLI project, using TypeScript / SASS. The IDE is Visual Studio 2015.

由Visual Studio或MSBuild构建项目时,在预编译目标中执行au build命令,因此当我使用F5从Visual Studio构建或运行ASP.NET Core项目时,Aurelia CLI将构建并捆绑Aurelia应用程序的资产也放入wwwroot.

When the project is built by Visual Studio or MSBuild, the au build command is executed in the precompilation target, so when I build or run the ASP.NET Core project from Visual Studio using F5, Aurelia CLI will build and bundle the assets for the Aurelia app into wwwroot as well.

此工作流程可确保正确构建任何解决方案更改,还可以确保.NET Core作为Web服务器运行,但是,对于开发人员而言,这很慢,因为对前端代码(HTML,SASS或TS)也需要完全重新编译/捆绑Aurelia应用.

This workflow ensures that any solution changes are correctly built, and it also ensures that .NET Core is running as the web server, however, it's slow for developers, because any changes to front-end code (HTML, SASS, or TS) that need to be made requires full recompilation / bundling of the Aurelia app as well.

最近对Aurelia CLI(0.25+)的更改大大加快了前端的构建,这虽然很棒,但仍然不是最佳选择.

Recent changes to the Aurelia CLI (0.25+) have sped up the front-end build a lot, which is great, but it's still not optimal.

我不能使用au run --watch,因为它不能运行.NET Core服务器.

I can't use au run --watch because that doesn't run the .NET Core server.

我正在寻找有关如何针对此配置优化开发人员工作流程的指南-理想情况下,按F5键应该可以像当前一样工作,但是还要在Aurelia中激活手表,以便对手表进行任何更改文件将触发Aurelia中的增量构建,该构建会直接更新浏览器.

I'm looking for guidance on how to optimize the developer workflow for this configuration - ideally, hitting F5 should work as it currently does, but with the addition of activating the watch in Aurelia as well, so that any changes to watched files will trigger an incremental build in Aurelia which updates the browser directly.

推荐答案

我们几乎专门使用au run --watch,但是我们仍然按照您的期望通过VS中的F5运行该应用程序.我们不在乎run命令实际上为文件提供服务(如果build命令上有监视标志,我们将改用au build --watch).我们会在首次打开项目时自动启动手表,然后我们可以使用gulpfile(请参见下文)和Task Runner Explorer窗口中定义的任务在一天中的工作过程中手动停止/重新启动它(因此我不需要打开控制台).这样,仅在实际更改服务器端代码时才需要重新编译服务器端代码.

We use au run --watch almost exclusively but we still run the app via F5 in VS as you would expect. We don't care that the run command actually serves the files (if there was a watch flag on the build command we would use au build --watch instead). We start the watch automatically when the project is first opened, then we can manually stop/restart it as we work throughout the day using tasks we defined in a gulpfile (see below) and the Task Runner Explorer window (so I don't need to have a console open). This way I only need to recompile the server side code when I actually change server side code.

我们没有设置浏览器同步,因此不会自动刷新浏览器,但是我们很好-我发现ctrl + R不会占用大量时间.

We don't have browsersync set up so this doesn't refresh the browser automatically, but we're fine with that - I don't find that ctrl+R is a big time sink.

在预发布步骤中,我们具有"au build --env prod",以确保构建机器执行生产构建.

We have "au build --env prod" in the prepublish step to make sure the build machine does a production build.

我们的gulpfile.js:

Our gulpfile.js:

var gulp = require('gulp');
var shell = require('gulp-shell');

gulp.task('build-dev', shell.task(['au build --env dev']));
gulp.task('watch', shell.task(['au run --watch']));
gulp.task('test', shell.task(['au test --watch']));
gulp.task('build-prod', shell.task(['au build --env prod']));

这篇关于如何使用Aurelia CLI/ASP.NET Core通过单个项目优化工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆