我正在尝试第一次在angular2-quickstart
部署local IIS
应用程序,并且是生产就绪构建过程的新手。
我的快速启动应用程序正常运行。
我已经添加了gulp到我的项目和我正在做的gulp是,
1)在根目录中创建dist文件夹。 dist
文件夹
2)将所有.ts
转换为.js
并将它们放在dist/app
下
3)创建dist/libs
,其中包含reflect.js
,shim.min.js
,system.src.js
,zone.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
,我在浏览器的控制台中看到以下内容。
7)我知道它的过程不完整但我想完成它并且不知道还需要什么其他东西。
现在的问题是,
1)我是否需要在systemjs.config.js中更改任何内容?如果有,那是什么?
2)正如你所看到的systemjs.config.js
使用node_modules
,为angular2 dependencies
做些什么?
3)如jquery
,hummerjs
等其他依赖项呢?
4)由于我不打算在node_modules
文件夹中有dist
文件夹,node_modules文件夹怎么样?
5)dist folders
中需要哪些其他文件?
我只需要将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
)
如果我们使用任务运行器为我们做这样的事情会更好,我正在寻找gulp配置和npm脚本来快速发布应用程序。
所以Angular2 QuickStart应该有npm脚本,例如npm run deploy,适合初学者。