1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-13 14:18:26 +09:00
cherrypick/webpack/module/rules/base64.ts

20 lines
433 B
TypeScript
Raw Normal View History

/**
* 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');
}
}]
})
});