在 MVC5 应用程序中使用打字稿并进行类似编译的捆绑
Using typescript in MVC5 application and do a bundle like compilation
我是 TypeScript 的新手,我问自己是否可以配置 TypeScript 的编译,例如 minification/bundling 和 JavaScript 以及 MVC5 中的 BundleConfig。
我的需求如下:
在使用 TypeScript 之前,我们有两个 js 包:"bundles/external" 和 "bundles/internal"。
"internal" 包有一些逻辑,我们只想向经过身份验证的用户公开。
但目前 VS TypeScript 编译器只能配置为将所有 .ts 文件编译并合并为一个文件。
有没有人有可以通过 "compile on save" 行为实现此行为的解决方案?
Does anyone has a solution which could achieve this behaviour with a "compile on save" behaviour?
关于您如何(我推荐)这样做的概述:
- 使用外部模块。用
--module commonjs
编译。 (reasons why out is bad)
- 使用 webpack https://webpack.github.io/ with code splitting : https://webpack.js.org/guides/code-splitting/(instagram.com 就是这样工作的!)
保存时编译现在更快!因为它只需要编译单个文件
我是 TypeScript 的新手,我问自己是否可以配置 TypeScript 的编译,例如 minification/bundling 和 JavaScript 以及 MVC5 中的 BundleConfig。
我的需求如下:
在使用 TypeScript 之前,我们有两个 js 包:"bundles/external" 和 "bundles/internal"。
"internal" 包有一些逻辑,我们只想向经过身份验证的用户公开。
但目前 VS TypeScript 编译器只能配置为将所有 .ts 文件编译并合并为一个文件。
有没有人有可以通过 "compile on save" 行为实现此行为的解决方案?
Does anyone has a solution which could achieve this behaviour with a "compile on save" behaviour?
关于您如何(我推荐)这样做的概述:
- 使用外部模块。用
--module commonjs
编译。 (reasons why out is bad) - 使用 webpack https://webpack.github.io/ with code splitting : https://webpack.js.org/guides/code-splitting/(instagram.com 就是这样工作的!)
保存时编译现在更快!因为它只需要编译单个文件