我使用Angular 2 / Gulp对应用程序进行编码。 使用Gulp部署代码后出现问题。
GET http://127.0.0.1/projects/myproject/angular2/router 404 (Not Found)
Error loading http://127.0.0.1/projects/myproject/angular2/router as "angular2/router" from http://127.0.0.1/projects/myproject/boot
at o (http://127.0.0.1/projects/myproject/vendors.min.js:7:842)
at XMLHttpRequest.L.a.onreadystatechange (http://127.0.0.1/projects/myproject/vendors.min.js:7:1430)
at XMLHttpRequest.t [as _onreadystatechange] (http://127.0.0.1/projects/myproject/vendors.min.js:6:3295)
at e.invokeTask (http://127.0.0.1/projects/myproject/vendors.min.js:5:31190)
at e.runTask (http://127.0.0.1/projects/myproject/vendors.min.js:5:28550)
at XMLHttpRequest.invoke (http://127.0.0.1/projects/myproject/vendors.min.js:6:285)
GET http://127.0.0.1/projects/myproject/angular2/http 404 (Not Found)
GET http://127.0.0.1/projects/myproject/lodash 404 (Not Found)
但是,从lite服务器(npm start)测试时没有问题。
我使用gulp构建我的vendor.min.js文件:
gulp.task('vendor-bundle', function () {
gulp.src([
'node_modules/jquery/dist/jquery.js',
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/rxjs/bundles/Rx.js',
'node_modules/angular2/bundles/angular2.dev.js',
'node_modules/lodash/lodash.js',
'node_modules/lodash/index.js',
'node_modules/angular2/bundles/http.dev.js',
'node_modules/angular2/bundles/router.min.js'
])
.pipe(concat('vendors.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
并在我的index.html中引用它:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MyWebstite</title>
<script src="vendors.min.js"></script>
<script src="app.min.js"></script>
</head>
<base href="/">
<!-- 3. Display the application -->
<body>
<master-page></master-page>
</body>
</html>
在我的boot.ts文件中,我导入引用:
import {bootstrap} from 'angular2/platform/browser'
import {provide} from "angular2/core"
import {ROUTER_DIRECTIVES,ROUTER_PROVIDERS} from "angular2/router"
import {HTTP_PROVIDERS} from "angular2/http"
import 'rxjs/add/operator/map'
import {MasterPage} from './components/pages/master-page/master-page.component'
var appPromise = bootstrap(<any>MasterPage, [
ROUTER_PROVIDERS
, HTTP_PROVIDERS]);
一个想法是将其更正为我的System.config脚本。 我已经搜索了一段时间没有任何成功的解决方案。有什么想法吗?