简体   繁体   English

Angular4 + MVC + cli +使用cli build命令生成的dist文件夹进行部署

[英]Angular4 + MVC + cli + deployment using dist folder generated from cli build command

I have an angular4 + MVC project. 我有一个angular4 + MVC项目。

I have a dist folder generated in angular through ng build --prod command in cli. 我在cli中通过ng build --prod命令生成了一个dist文件夹。

I want to eliminate node modules and checkin only these dist files for production. 我想消除节点模块并仅检查这些dist文件以进行生产。

My problem is how can i point to start execution using /dist folder instead of /node modules . 我的问题是如何指向使用/ dist文件夹而不是/ node模块开始执行。

Currently i am using system.import() from my layout.cshtml(in mvc) to import app module of angular. 目前我正在使用我的layout.cshtml(在mvc中)中的system.import()来导入角度的app模块。

 <script>
System.import('app/main.js').catch(function (err) { console.error(err); });

Also what should be the content in systemjs.config file since my intention is to eliminate node modules, and presently ** systemjs.config ** points to open node modules folder. 还有什么应该是systemjs.config文件中的内容,因为我的目的是消除节点模块,目前** systemjs.config **指向打开节点模块文件夹。

(function (global) {System.config({
paths: {
  'npm:': 'node_modules/'
},
map: {
  'app': 'app',
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
  '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',

etc. etc. 等等

Any help would be highly appreciated. 任何帮助将受到高度赞赏。

Its all about index.html in your build - which holds all your script part and polyfills 所有关于你的构建中的index.html - 它包含你所有的脚本部分和polyfill

Just add your index.html from the dist folder to your cshtml file and map your script and style to the folder where you have your builds 只需将您的index.html从dist文件夹添加到您的cshtml文件,并将您的脚本和样式映射到您构建的文件夹

you need to deploy only your prod build nothing more than that is required - you can exclude your node modules and check in your changes 您只需要部署您的prod构建,只需要 - 您可以排除节点模块并检入更改

Thanks !! 谢谢 !! Happy coding 快乐的编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM