js 파일을 생성하는 typescript가있는 각도 2 응용 프로그램이 있습니다.Gulp : Error : 복수 익명 System.register (모듈에서 호출)를 사용하여 각도 2의 시스템 가져 오기에서 번들 파일을로드하는 방법
최근에 npm과 gulp를 설치하고 js 파일을 모두 하나로 묶어서 단일 파일로로드하는 방법을 설명했습니다. 이전 내 index.html 페이지에서
: // 메인이 appComponent
부트 스트랩 구성 요소입니다 작동하는<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js',
defaultJSExtensions: true
}
}
});
debugger;
//System.import('Scripts/main')
System.import('app/V1/components/main')
.then(null, console.error.bind(console));
</script>
내 꿀꺽 작업 :
var config = {
src: ['app/**/*.js'],
dest: ['Scripts/']
};
gulp.task('bundle', function() {
console.log('testing');
return gulp.src(config.src)
.pipe(uglify())
.pipe(concat('all.min.js'))
.pipe(gulp.dest('app/'));
})
나는이 꿀꺽 꿀꺽 작업을 실행할 때 그것은 all.min.js를 생성하지만 이것을 사용하는 방법 즉, System.import에서 main.js를 제거하고로드하는 방법입니다.
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js',
defaultJSExtensions: true
}
},
map: {
immutable: 'app/all.min.js'
}
});
debugger;
//System.import('Scripts/main')
System.import('app/all.min')
.then(null, console.error.bind(console));
</script>
여러 익명 System.register 모듈
http://localhost:55308/app/all.min.js에서 호출 6,
나는
오류로 오류를 던지고있다이 방법을 시도했다. 번들을로드하는 경우 모든 System.register 호출의 이름이 지정되었는지 확인하십시오.
시간을 내 주셔서 감사합니다. 내가 마지막으로 스크립트를 넣은 것을 의미합니다. 예를 들어 System.config.js라는 시스템 js 파일로 참조하는 별도로 배치해야합니다. – sudhir
여기서 total.js 및 main .js는 무엇입니까? Systemjs 파일에 대해서도 언급하는 것이 좋을 것입니다. – sudhir
total.js는 모든 응용 프로그램 파일이고 main.js는 모든 종속성과 함께 컴파일되고 uglified 된 파일입니다. system.config.js는 다음과 유사해야합니다 (페이지 하단의 system.config.js를 확인하십시오) : https://angular.io/docs/ts/latest/quickstart.html –