オフラインでも画像を表示できるようにbase64にして埋め込むようにした

This commit is contained in:
こぴなたみぽ
2017-10-22 14:11:28 +09:00
parent efba945e37
commit 5f40e7eaa4
3 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,19 @@
/**
* Replace base64 symbols
*/
import * as fs from 'fs';
const StringReplacePlugin = require('string-replace-webpack-plugin');
export default () => ({
enforce: 'pre',
test: /\.(tag|js)$/,
exclude: /node_modules/,
loader: StringReplacePlugin.replace({
replacements: [{
pattern: /%base64:(.+?)%/g, replacement: (_, key) => {
return fs.readFileSync(__dirname + '/../../../src/web/' + key, 'base64');
}
}]
})
});