aspnetcore-spa(webpack)-在单独的项目中使用时会生成不需要的js文件 [英] aspnetcore-spa (webpack) - when used in separate project builds unwanted js files

查看:96
本文介绍了aspnetcore-spa(webpack)-在单独的项目中使用时会生成不需要的js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对aspnetcore-spa功能有疑问.我试图做的是基于一个单独项目中的yeoman(带有angular2)的示例项目来实现它.但我怀疑我遇到问题是由于缺少某些配置或某些原因引起的.为了解释我的工作,以下过程说明了该问题:

I have a questions in regards to the aspnetcore-spa functionality. What im trying to do is to implement it based on the sample project from yeoman (with angular2) in a SEPARATE project. But im running into an issue with i suspect is caused by some missing configuration or something. To explain what i do the following procedure illustrates the problem:

  1. 我使用"yo aspnetcore-spa"生成了一个示例项目,并选择了angular2.
  2. 我创建了一个空的.net核心项目.
  3. 我将相关文件从示例项目复制到了新项目中.结果可见于: https://github.com/baseless/AspNetCoreSpaQDemo

结果

生成的示例项目按预期运行.在VS中查看时,不会基于ClientApp中的ts文件生成.js文件.如果我在例如counter.ts文件中更改了属性,它会在浏览器中按需更新.

The generated sample project runs as expected. When looking in VS no .js files were generated based on the ts files in ClientApp. If i change a property in for example counter.ts file it is updated in browser as it should.

创建的具有复制文件的项目,但是在构建过程中确实会生成.js文件.然后,Webpack似乎会使用这些文件,因此,如果我更改counter.ts文件中的属性,则浏览器中不会发生任何更改.但是,如果我删除匹配的counter.js文件,则会将counter.ts文件重建为js并更新浏览器.

The created project with copied files however DO generate .js files during build. Webpack then seems to use these files so if i change property in counter.ts file, nothing is changed in browser. HOWEVER if i delete the matching counter.js file, the counter.ts file is rebuilt to js and browser updated.

查找问题的原因是什么原因,因为我在两个项目中都使用了相同的项目,webpack等配置文件.我对Webpack完全是绿色的,所以也许需要运行某些东西?要使它正常工作还需要其他东西吗?

What im having trouble finding is what causes this, since im just using the same project, webpack and so forth configuration files in both projects. I am totally green to webpack so perhaps something that need to be run? Are there something else that is needed for this to work?

推荐答案

对示例项目进行了一些检查,这是由xproj设置引起的,该设置禁用了自动打字稿编译功能.以为它与webpack有关,但是在我将<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>添加到我的ProjectName.xproj文件中之后,一切正常.

Did some examination of the sample project and it was caused by an xproj setting to disable automatic typescript compilation. Thought it had something to do with webpack but everything worked fine after i added <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> to my ProjectName.xproj file.

这篇关于aspnetcore-spa(webpack)-在单独的项目中使用时会生成不需要的js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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