calckey/webpack/module/rules/base64.ts

19 lines
337 B
TypeScript
Raw Normal View History

/**
* Replace base64 symbols
*/
import * as fs from 'fs';
export default () => ({
enforce: 'pre',
2018-02-13 04:18:03 +00:00
test: /\.(vue|js)$/,
exclude: /node_modules/,
2018-02-15 14:07:19 +00:00
loader: 'string-replace-loader',
query: {
search: /%base64:(.+?)%/g,
replace: (_, key) => {
return fs.readFileSync(__dirname + '/../../../src/web/' + key, 'base64');
2018-02-15 10:59:07 +00:00
}
2018-02-15 14:07:19 +00:00
}
});