summaryrefslogtreecommitdiff
path: root/webpack/plugins
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-11-23 06:51:32 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-11-23 06:51:32 +0900
commitdd85278d54e7bef392e44ccf22cf49fe595a36d6 (patch)
tree44c6f6425605a62ac427c4ca134f984146d7e206 /webpack/plugins
parentv3194 (diff)
downloadsharkey-dd85278d54e7bef392e44ccf22cf49fe595a36d6.tar.gz
sharkey-dd85278d54e7bef392e44ccf22cf49fe595a36d6.tar.bz2
sharkey-dd85278d54e7bef392e44ccf22cf49fe595a36d6.zip
Fix bug
Diffstat (limited to 'webpack/plugins')
-rw-r--r--webpack/plugins/consts.ts37
-rw-r--r--webpack/plugins/index.ts2
2 files changed, 39 insertions, 0 deletions
diff --git a/webpack/plugins/consts.ts b/webpack/plugins/consts.ts
new file mode 100644
index 0000000000..7d1ff7c8d5
--- /dev/null
+++ b/webpack/plugins/consts.ts
@@ -0,0 +1,37 @@
+/**
+ * Constant Replacer
+ */
+
+import * as webpack from 'webpack';
+
+import version from '../../src/version';
+const constants = require('../../src/const.json');
+import config from '../../src/conf';
+
+export default lang => {
+ const consts = {
+ _RECAPTCHA_SITEKEY_: config.recaptcha.site_key,
+ _SW_PUBLICKEY_: config.sw ? config.sw.public_key : null,
+ _THEME_COLOR_: constants.themeColor,
+ _VERSION_: version,
+ _STATUS_URL_: config.status_url,
+ _STATS_URL_: config.stats_url,
+ _ABOUT_URL_: config.about_url,
+ _API_URL_: config.api_url,
+ _DEV_URL_: config.dev_url,
+ _CH_URL_: config.ch_url,
+ _LANG_: lang,
+ _HOST_: config.host,
+ _URL_: config.url,
+ };
+
+ const _consts = {};
+
+ Object.keys(consts).forEach(key => {
+ _consts[key] = JSON.stringify(consts[key]);
+ });
+
+ return new webpack.DefinePlugin(Object.assign({}, _consts, {
+ __CONSTS__: JSON.stringify(consts)
+ }));
+};
diff --git a/webpack/plugins/index.ts b/webpack/plugins/index.ts
index 24782a1de6..3d1416d1ea 100644
--- a/webpack/plugins/index.ts
+++ b/webpack/plugins/index.ts
@@ -1,5 +1,6 @@
const StringReplacePlugin = require('string-replace-webpack-plugin');
+import consts from './consts';
import hoist from './hoist';
//import minify from './minify';
import banner from './banner';
@@ -9,6 +10,7 @@ const isProduction = env === 'production';
export default (version, lang) => {
const plugins = [
+ consts(lang),
new StringReplacePlugin(),
hoist()
];