简体   繁体   中英

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

I have an angular4 + MVC project.

I have a dist folder generated in angular through ng build --prod command in cli.

I want to eliminate node modules and checkin only these dist files for production.

My problem is how can i point to start execution using /dist folder instead of /node modules .

Currently i am using system.import() from my layout.cshtml(in mvc) to import app module of angular.

 <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.

(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

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

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

Thanks !! Happy coding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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