我想用baseURL配置systemjs.config,因为我的应用程序位于其他文件夹中。尝试加载时,我收到404错误
/SPA/SPA/App.main.js
而不是SPA/App.main.js
SiteRoot
--- SPA
--------- App
-------------- Main.js
--- system.src.js
--- systemjs.config.js
--- gulp.js
SystemJs.config
(function (global) {
System.config({
baseURL: "SPA",
paths: {
"npm:": "node_modules/"
},
map: {
app: "App",
// angular bundles
"@angular/core": "npm:@angular/core/bundles/core.umd.js"
// all other angular bundles
// other libraries
"rxjs": "npm:rxjs",
"tslib": "npm:tslib/tslib.js"
},
packages: {
app: { main: "main.js", defaultExtension: "js" },
rxjs: { defaultExtension: "js" }
},
meta: {
"*": { authorization: true }
}
});
})(this);
SPA / index.html
<base href="/SPA/" />
<script src="../system.src.js"></script>
<script src="../systemjs.config.js"></script>
<script>
System.import('app').catch(function (err) { console.error(err); });
</script>
Gulp.js
var SystemJsBuilder = require('systemjs-builder');
var paths = {
npm: 'node_modules/',
app: 'SPA/App/',
appBundle: 'SPA/App/app.bundle.js'
};
gulp.task('release:bundle-app', ['delete:app-bundle', 'release:embed-templates'], function () {
var builder = new SystemJsBuilder('./', 'systemjs.config.js');
var buildStatic = builder.buildStatic('SPA/App/main.js', paths.appBundle, { minify: true, sourceMaps: false });
return buildStatic;
});
gulp.task('release:bundle-rxjs', function () {
var options = {
normalize: false,
runtime: false,
sourceMaps: false,
sourceMapContents: false,
minify: false,
mangle: false
};
var builder = new SystemJsBuilder('./');
builder.config({
paths: {
//'n:*': 'node_modules/*',
'rxjs/*': 'node_modules/rxjs/*.js'
},
map: { 'rxjs': 'node_modules/rxjs' },
packages: { 'rxjs': { main: 'Rx.js', defaultExtension: 'js' } }
});
return builder.bundle('rxjs', paths.libs + 'rxjs/rxjs.js', options);
});
我不确定配置中出现了什么问题,并试图找出最近几天的结果,但没有任何效果。
当应用程序在子文件夹中运行时,如何配置systemjs.config?我还将这个systemjs.config加载到gulp.js中,因此将其放在根目录中。