diff options
| author | こぴなたみぽ <syuilotan@yahoo.co.jp> | 2017-10-22 14:11:28 +0900 |
|---|---|---|
| committer | こぴなたみぽ <syuilotan@yahoo.co.jp> | 2017-10-22 14:11:28 +0900 |
| commit | 5f40e7eaa46fd8a3f60d2306a21364e38db73012 (patch) | |
| tree | 5f3ea67dc29b4a9c5e2415a36373710826f37fbe /webpack/module | |
| parent | Merge pull request #835 from syuilo/greenkeeper/webpack-3.8.1 (diff) | |
| download | sharkey-5f40e7eaa46fd8a3f60d2306a21364e38db73012.tar.gz sharkey-5f40e7eaa46fd8a3f60d2306a21364e38db73012.tar.bz2 sharkey-5f40e7eaa46fd8a3f60d2306a21364e38db73012.zip | |
オフラインでも画像を表示できるようにbase64にして埋め込むようにした
Diffstat (limited to 'webpack/module')
| -rw-r--r-- | webpack/module/rules/base64.ts | 19 | ||||
| -rw-r--r-- | webpack/module/rules/index.ts | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/webpack/module/rules/base64.ts b/webpack/module/rules/base64.ts new file mode 100644 index 0000000000..529816bd20 --- /dev/null +++ b/webpack/module/rules/base64.ts @@ -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'); + } + }] + }) +}); diff --git a/webpack/module/rules/index.ts b/webpack/module/rules/index.ts index 2707a9c2f1..9c1262b3d6 100644 --- a/webpack/module/rules/index.ts +++ b/webpack/module/rules/index.ts @@ -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(), |