Skip to content

Commit

Permalink
fix: making it possible to inject source map files into html (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimbeng committed May 18, 2016
1 parent 8078cd9 commit 7649b38
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/inject/expected/issue176.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>gulp-inject</title>
</head>
<body>

<!-- inject:js-->
<script src="/fixtures/lib.js"></script>
<!-- endinject-->
<!-- inject:map-->
<script src="/fixtures/lib.js.map"></script>
<!-- endinject-->
</body>
</html>
13 changes: 13 additions & 0 deletions src/inject/fixtures/issue176.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>gulp-inject</title>
</head>
<body>

<!-- inject:js-->
<!-- endinject-->
<!-- inject:map-->
<!-- endinject-->
</body>
</html>
1 change: 0 additions & 1 deletion src/inject/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ function getNewContent(target, collection, opt) {
var startTag = files[0].startTag;
var endTag = files[0].endTag;
var tagsToInject = getTagsToInject(files, target, opt);

content = inject(content, {
startTag: startTag,
endTag: endTag,
Expand Down
12 changes: 12 additions & 0 deletions src/inject/inject_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,18 @@ describe('gulp-inject', function () {
streamShouldContain(stream, ['issue107.html'], done);
});

it('should be able to inject source maps (Issue #176)', function (done) {
var target = src(['issue176.html'], {read: true});
var sources = src([
'lib.js',
'lib.js.map'
]);

var stream = target.pipe(inject(sources));

streamShouldContain(stream, ['issue176.html'], done);
});

it('should be able to empty tags when there are no files for that tag and empty option is set', function (done) {
var target = src(['templateWithExistingData2.html'], {read: true});
var sources = src([
Expand Down
1 change: 1 addition & 0 deletions src/transform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ transform.html.css = function (filepath) {
transform.html.js = function (filepath) {
return '<script src="' + filepath + '"></script>';
};
transform.html.map = transform.html.js;

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

0 comments on commit 7649b38

Please sign in to comment.