diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-12-11 03:38:31 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-12-11 03:38:31 +0900 |
| commit | 845dc261846661359d38fccea0f84b99ed6968e5 (patch) | |
| tree | 623341e642991b495129f90b81e80ce126d13d0a /webpack | |
| parent | #983 (diff) | |
| download | sharkey-845dc261846661359d38fccea0f84b99ed6968e5.tar.gz sharkey-845dc261846661359d38fccea0f84b99ed6968e5.tar.bz2 sharkey-845dc261846661359d38fccea0f84b99ed6968e5.zip | |
:v:
Diffstat (limited to 'webpack')
| -rw-r--r-- | webpack/module/rules/index.ts | 2 | ||||
| -rw-r--r-- | webpack/module/rules/license.ts | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/webpack/module/rules/index.ts b/webpack/module/rules/index.ts index 79740ce48e..b6a0a5e2ec 100644 --- a/webpack/module/rules/index.ts +++ b/webpack/module/rules/index.ts @@ -1,4 +1,5 @@ import i18n from './i18n'; +import license from './license'; import fa from './fa'; import base64 from './base64'; import themeColor from './theme-color'; @@ -8,6 +9,7 @@ import typescript from './typescript'; export default (lang, locale) => [ i18n(lang, locale), + license(), fa(), base64(), themeColor(), diff --git a/webpack/module/rules/license.ts b/webpack/module/rules/license.ts new file mode 100644 index 0000000000..1795af960d --- /dev/null +++ b/webpack/module/rules/license.ts @@ -0,0 +1,22 @@ +/** + * Inject license + */ + +import * as fs from 'fs'; +const StringReplacePlugin = require('string-replace-webpack-plugin'); + +const license = fs.readFileSync(__dirname + '/../../../LICENSE', 'utf-8') + .replace(/\r\n/g, '\n') + .replace(/(.)\n(.)/g, '$1 $2') + .replace(/(^|\n)(.*?)($|\n)/g, '<p>$2</p>'); + +export default () => ({ + enforce: 'pre', + test: /\.(tag|js)$/, + exclude: /node_modules/, + loader: StringReplacePlugin.replace({ + replacements: [{ + pattern: '%license%', replacement: () => license + }] + }) +}); |