在 systemjs.config.js 中做这样的事情:
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',
'angularstuffhere':'angularstuffhere'
},
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
在 Index.html 中
<app-root>Loading Client...</app-root>
现在在 app 文件夹中创建您的 app.module 并引用 app/App1/app 和 app/App2/app;它可能有组件,也可能是模块本身。这是您可能需要的。
如果您想要两个不同的不相关应用程序,请在您的 systemjs.config.js 中执行以下操作(不需要两个 systemjs.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: 'App1/app',
app2: 'App2/app',
'angularstuffhere':'angularstuffhere'
},
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
在 Index.html 中
<app1-root>Loading Client...</app1-root>
<app2-root>Loading Client...</app2-root>
更新:
尝试将 bsconfig.json 的服务文件夹更改为以下内容:
"baseDir": "dirofyourapp",
由于您有编译问题,请在 package.json 中更改以下内容:
"scripts": {
"build": "tsc -p dirofyourapp/",
"build:watch": "tsc -p dirofyourapp/ -w",
"build:e2e": "tsc -p e2edirofyourapp/",
您将无法使用一组脚本运行不同的应用程序,您必须在 package.json 中创建自己的自定义脚本
如果您想要一个可重用的代码,那么创建一个可重用的独立模块并通过导入在您的应用程序中使用它,而不是创建一个复杂的不可维护的开发环境。
一个如何创建可供许多应用程序使用的可重用模块的示例:
https://github.com/primefaces/primeng/blob/master/src/app/components/chart/chart.ts