diff --git a/src/writeFile.js b/src/writeFile.js index 43c86d6b..3abff673 100644 --- a/src/writeFile.js +++ b/src/writeFile.js @@ -26,6 +26,8 @@ export default function writeFile(globalRef, pattern, file) { content = pattern.transform(content, file.absoluteFrom); } + return content; + }).then((content) => { var hash = loaderUtils.getHashDigest(content); if (pattern.toType === 'template') { diff --git a/tests/index.js b/tests/index.js index 3c5b9ed0..cb66a021 100644 --- a/tests/index.js +++ b/tests/index.js @@ -799,6 +799,27 @@ describe('apply function', () => { .then(done) .catch(done); }); + + it('transform with promise', (done) => { + runEmit({ + expectedAssetKeys: [ + 'file.txt' + ], + expectedAssetContent: { + 'file.txt': 'newchanged!' + }, + patterns: [{ + from: 'file.txt', + transform: function(content) { + return new Promise((resolve) => { + resolve(content + 'changed!'); + }); + } + }] + }) + .then(done) + .catch(done); + }); }); describe('with directory in from', () => {