私は、JavaScriptを読み込むためにSystemJSを使うAngular 2 RC7アプリを持っています。角2:SystemJSにバンドルを使用するように指示する方法は?
これはSystemJSのための私の現在の設定です:
(function (global) {
System.config({
defaultExtension: 'js',
defaultJSExtensions: true,
paths: {
'npm:': 'node_modules/'
},
// Let the system loader know 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',
'ng2-translate': 'node_modules/ng2-translate'
},
// Tell the system loader how to load when no filename and/or no extension
packages: {
app: { main: './main.js', defaultExtension: 'js' },
rxjs: { defaultExtension: 'js' },
'ng2-translate': { defaultExtension: 'js' }
}
});
})(this);
今、私はすべての私のアプリのロジックが含まれていapp.bundle.min.js
呼ばバンドル、および使用の依存関係が含まれているdependencies.bundle.min.js
を作成しました。
ファイルを個別にインポートする代わりに、これらのファイルを使用するようにSystemJSに指示する方法を教えてください。
私はこれを交換しようとしている:私のindex.htmlに
<script src="production/dependencies.bundle.min.js"></script>
<script src="production/app.bundle.min.js"></script>
、それは働いていない:と
<script>
System.import('app').catch(function(err){
console.error(err);
});
</script>
。私がSystem.import...
スクリプトブロックをindex.html内に保持している限り、アプリケーションはロードしますが、バンドルではなく個々のファイルを使用します。
また、私は、これを変更しようとした:
map: {
// Our app is within the app folder
app: 'production/app.bundle.min.js',
が、それはどちらか動作しませんでした。
これは、バンドルががぶ飲みを使用して生成される方法である:私は何とかバンドルに向けて指すように私のSystemJS構成内のマッピングを変更する必要が疑われる
gulp.task('inline-templates', function() {
return gulp.src('app/**/*.ts')
.pipe(inlineNg2Template({
UseRelativePaths: true,
indent: 0,
removeLineBreaks: true
}))
.pipe(tsc({
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true
}))
.pipe(gulp.dest('dist'));
});
gulp.task('bundle-app', ['inline-templates'], function() {
var builder = new systemjsBuilder('', 'app/configs/systemjs.config.js');
return builder
.bundle('dist/**/* - [@angular/**/*.js] - [rxjs/**/*.js]', 'production/app.bundle.min.js', {
minify: true,
mangle: true
})
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});
});
gulp.task('bundle-dependencies', ['inline-templates'], function() {
var builder = new systemjsBuilder('', 'app/configs/systemjs.config.js');
return builder
.bundle('dist/**/*.js - [dist/**/*.js]', 'production/dependencies.bundle.min.js', {
minify: true,
mangle: true
})
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});
});
gulp.task('production', ['bundle-app', 'bundle-dependencies'], function(){});
?これはどうすればいいですか?
https://github.com/fictitious/test-systemjs-angular-gulpがバンドルは、私は私の質問にゴクゴクタスクを追加した – artem
を生成している正確にどのように知らずに伝えるために。 –