https://github.com/jhades/angularjs-gulp-example/blob/master/gulpfile.js의 링크는 bundle.a3503174.js
이라는 이름의 번들 파일을 생성하는 것처럼 보입니다. 그러나 html에서 bundle.js
으로 참조됩니다. 어떻게 작동합니까? 이름이 md5 체크섬 번호로 확장되었지만 시스템이 올바른 번들 파일을 볼 위치를 어떻게 알 수 있습니까?`cachebust.resources()`가`bundle.a3503174.js`를 생성 한 후에`bundle.js`를 html에서 참조하는 방법은 무엇입니까?
0
A
답변
0
질문의 링크는 실제로 gulp-cachebust
을 사용하여 번들을 만든 다음 index.html 내의 해당 번들에 대한 참조를 적절한 파일 이름으로 다시 작성합니다. 이 키는 다음 코드 행에있는 cachebust.references()
문에 있습니다.
gulp.task('build', [ 'clean', 'bower','build-css','build-template-cache', 'jshint', 'build-js'], function() {
return gulp.src('index.html')
.pipe(cachebust.references())
.pipe(gulp.dest('dist')); });
그래서 비록 된 index.html의 비 단숨에 버전 내의 기준 링크 /dist/js/bundle.js
이다. 이 참조는 index.html의 gulp 버전에 js/bundle.a3503174.js
으로 다시 작성됩니다.