Skip to content

Commit 7649b38

Browse files
committed
fix: making it possible to inject source map files into html (closes #176)
1 parent 8078cd9 commit 7649b38

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

src/inject/expected/issue176.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>gulp-inject</title>
5+
</head>
6+
<body>
7+
8+
<!-- inject:js-->
9+
<script src="/fixtures/lib.js"></script>
10+
<!-- endinject-->
11+
<!-- inject:map-->
12+
<script src="/fixtures/lib.js.map"></script>
13+
<!-- endinject-->
14+
</body>
15+
</html>

src/inject/fixtures/issue176.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>gulp-inject</title>
5+
</head>
6+
<body>
7+
8+
<!-- inject:js-->
9+
<!-- endinject-->
10+
<!-- inject:map-->
11+
<!-- endinject-->
12+
</body>
13+
</html>

src/inject/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ function getNewContent(target, collection, opt) {
124124
var startTag = files[0].startTag;
125125
var endTag = files[0].endTag;
126126
var tagsToInject = getTagsToInject(files, target, opt);
127-
128127
content = inject(content, {
129128
startTag: startTag,
130129
endTag: endTag,

src/inject/inject_test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,18 @@ describe('gulp-inject', function () {
585585
streamShouldContain(stream, ['issue107.html'], done);
586586
});
587587

588+
it('should be able to inject source maps (Issue #176)', function (done) {
589+
var target = src(['issue176.html'], {read: true});
590+
var sources = src([
591+
'lib.js',
592+
'lib.js.map'
593+
]);
594+
595+
var stream = target.pipe(inject(sources));
596+
597+
streamShouldContain(stream, ['issue176.html'], done);
598+
});
599+
588600
it('should be able to empty tags when there are no files for that tag and empty option is set', function (done) {
589601
var target = src(['templateWithExistingData2.html'], {read: true});
590602
var sources = src([

src/transform/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ transform.html.css = function (filepath) {
5353
transform.html.js = function (filepath) {
5454
return '<script src="' + filepath + '"></script>';
5555
};
56+
transform.html.map = transform.html.js;
5657

5758
transform.html.jsx = function (filepath) {
5859
return '<script type="text/jsx" src="' + filepath + '"></script>';

0 commit comments

Comments
 (0)