mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 13:13:08 +02:00
オフラインでも画像を表示できるようにbase64にして埋め込むようにした
This commit is contained in:
parent
efba945e37
commit
5f40e7eaa4
3 changed files with 22 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<mk-error>
|
||||
<img src="/assets/error.jpg" alt=""/>
|
||||
<img src="data:image/jpeg;base64,%base64:/assets/error.jpg%" alt=""/>
|
||||
<h1>%i18n:common.tags.mk-error.title%</h1>
|
||||
<p class="text">%i18n:common.tags.mk-error.description%</p>
|
||||
<p class="thanks">%i18n:common.tags.mk-error.thanks%</p>
|
||||
|
|
19
webpack/module/rules/base64.ts
Normal file
19
webpack/module/rules/base64.ts
Normal 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');
|
||||
}
|
||||
}]
|
||||
})
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import i18n from './i18n';
|
||||
import base64 from './base64';
|
||||
import themeColor from './theme-color';
|
||||
import tag from './tag';
|
||||
import stylus from './stylus';
|
||||
|
@ -6,6 +7,7 @@ import typescript from './typescript';
|
|||
|
||||
export default (lang, locale) => [
|
||||
i18n(lang, locale),
|
||||
base64(),
|
||||
themeColor(),
|
||||
tag(),
|
||||
stylus(),
|
||||
|
|
Loading…
Reference in a new issue