UNPKG

@webpack-contrib/defaults

Version:

Project configuration and boilerplate defaults for webpack projects

24 lines (17 loc) 517 B
import path from 'path'; export default (asset, compiler, stats) => { const usedFs = compiler.outputFileSystem; const outputPath = stats.compilation.outputOptions.path; let data = ''; let targetFile = asset; const queryStringIdx = targetFile.indexOf('?'); if (queryStringIdx >= 0) { targetFile = targetFile.substr(0, queryStringIdx); } try { data = usedFs.readFileSync(path.join(outputPath, targetFile)).toString(); } catch (error) { data = error.toString(); } return data; };