如何将angular2-quickstart应用程序部署到IIS

问题描述 投票:2回答:2

我正在尝试第一次在angular2-quickstart部署local IIS应用程序,并且是生产就绪构建过程的新手。

我的快速启动应用程序正常运行。

我已经添加了gulp到我的项目和我正在做的gulp是,

enter image description here

1)在根目录中创建dist文件夹。 dist文件夹

2)将所有.ts转换为.js并将它们放在dist/app

3)创建dist/libs,其中包含reflect.jsshim.min.jssystem.src.jszone.js,如图所示。

4)systemjs.config.js如下(请注意:我尚未对现有文件进行任何更改),

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

5)index.html如下,

<!DOCTYPE html>
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">



     <!-- changed this section with libs -->


      <script src='lib/shim.min.js'></script>
      <script src='lib/zone.js'></script>
      <script src='lib/Reflect.js'></script>
      <script src='lib/system.src.js'></script>
      <script src="https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js"></script>
      <script src="systemjs.config.js"></script>

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



  </head>

  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>
</html>

6)我将dist folder's内容复制到c:/inetpub/wwwroot并尝试访问localhost中的chrome browser,我在浏览器的控制台中看到以下内容。

enter image description here

7)我知道它的过程不完整但我想完成它并且不知道还需要什么其他东西。


现在的问题是,

1)我是否需要在systemjs.config.js中更改任何内容?如果有,那是什么?

2)正如你所看到的systemjs.config.js使用node_modules,为angular2 dependencies做些什么?

3)如jqueryhummerjs等其他依赖项呢?

4)由于我不打算在node_modules文件夹中有dist文件夹,node_modules文件夹怎么样?

5)dist folders中需要哪些其他文件?

angular deployment iis-8
2个回答
0
投票

我只需要将node_modules文件夹复制到c:/inetpub/wwwroot/并繁荣。现在它按预期工作。

所以最后我的c:/inetput/wwwroot文件夹包含下面的文件夹成功运行angular2 app,

应用 | _______ app.component.js | _______ app.module.js | _______ main.js LIB | _______ Reflect.js | _______ shim.min.js | _______ system.src.js | _______ zone.js node_modules(just copy paste) index.html的(changed script's path, refer above index.html) systemjs.config.js(no change


-1
投票

如果我们使用任务运行器为我们做这样的事情会更好,我正在寻找gulp配置和npm脚本来快速发布应用程序。

所以Angular2 QuickStart应该有npm脚本,例如npm run deploy,适合初学者。

© www.soinside.com 2019 - 2024. All rights reserved.