diff --git a/index.js b/index.js index 85a21f3..6dafe6c 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,8 @@ var fs = require('fs'), es = require('event-stream'), gutil = require('gulp-util'), glob = require('glob'), - applySourceMap = require('vinyl-sourcemaps-apply'); + applySourceMap = require('vinyl-sourcemaps-apply'), + stripBom = require('strip-bom'); var SourceMapGenerator = require('source-map').SourceMapGenerator; var SourceMapConsumer = require('source-map').SourceMapConsumer; @@ -134,7 +135,8 @@ function processInclude(content, filePath, sourceMap) { if (!inExtensions(globbedFilePath)) continue; // Get file contents and apply recursive include on result - var fileContents = fs.readFileSync(globbedFilePath); + // Unicode byte order marks are stripped from the start of included files + var fileContents = stripBom(fs.readFileSync(globbedFilePath)); var result = processInclude(fileContents.toString(), globbedFilePath, sourceMap); var resultContent = result.content; diff --git a/package.json b/package.json index 22c3df4..bacf00f 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "glob": "^5.0.12", "gulp-util": "~2.2.10", "source-map": "^0.5.1", + "strip-bom": "^2.0.0", "vinyl-sourcemaps-apply": "^0.2.0" } } diff --git a/test/expected/html/basic-include-output-with-unicode-BOM.html b/test/expected/html/basic-include-output-with-unicode-BOM.html new file mode 100644 index 0000000..8e79b38 --- /dev/null +++ b/test/expected/html/basic-include-output-with-unicode-BOM.html @@ -0,0 +1,10 @@ + + +
+ +