mirror of
https://github.com/hotomoe/hotomoe
synced 2024-11-28 23:08:17 +09:00
Fix bug
This commit is contained in:
parent
25981c15db
commit
dd85278d54
@ -5,7 +5,9 @@
|
||||
declare const _VERSION_: string;
|
||||
declare const _LANG_: string;
|
||||
declare const _HOST_: string;
|
||||
declare const __CONSTS__: any;
|
||||
|
||||
import * as riot from 'riot';
|
||||
import checkForUpdate from './common/scripts/check-for-update';
|
||||
import mixin from './common/mixins';
|
||||
import MiOS from './common/mios';
|
||||
@ -34,6 +36,9 @@ if (_HOST_ != 'localhost') {
|
||||
head.appendChild(meta);
|
||||
}
|
||||
|
||||
// Set global configuration
|
||||
(riot as any).mixin(__CONSTS__);
|
||||
|
||||
// iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
|
||||
try {
|
||||
localStorage.setItem('kyoppie', 'yuppie');
|
||||
|
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* Replace consts
|
||||
*/
|
||||
|
||||
const StringReplacePlugin = require('string-replace-webpack-plugin');
|
||||
|
||||
import version from '../../../src/version';
|
||||
const constants = require('../../../src/const.json');
|
||||
import config from '../../../src/conf';
|
||||
|
||||
export default lang => {
|
||||
// 置換の誤爆を防ぐため文字数の多い順に並べてください
|
||||
const consts = {
|
||||
_RECAPTCHA_SITEKEY_: JSON.stringify(config.recaptcha.site_key),
|
||||
_SW_PUBLICKEY_: config.sw ? JSON.stringify(config.sw.public_key) : JSON.stringify(null),
|
||||
_THEME_COLOR_: JSON.stringify(constants.themeColor),
|
||||
_VERSION_: JSON.stringify(version),
|
||||
_STATUS_URL_: JSON.stringify(config.status_url),
|
||||
_STATS_URL_: JSON.stringify(config.stats_url),
|
||||
_ABOUT_URL_: JSON.stringify(config.about_url),
|
||||
_API_URL_: JSON.stringify(config.api_url),
|
||||
_DEV_URL_: JSON.stringify(config.dev_url),
|
||||
_CH_URL_: JSON.stringify(config.ch_url),
|
||||
_LANG_: JSON.stringify(lang),
|
||||
_HOST_: JSON.stringify(config.host),
|
||||
_URL_: JSON.stringify(config.url),
|
||||
};
|
||||
|
||||
const replacements = Object.keys(consts).map(key => ({
|
||||
pattern: new RegExp(key, 'g'), replacement: () => consts[key]
|
||||
}));
|
||||
|
||||
return {
|
||||
enforce: 'post',
|
||||
test: /\.(tag|js|ts)$/,
|
||||
exclude: /node_modules/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: replacements
|
||||
})
|
||||
};
|
||||
};
|
@ -1,5 +1,4 @@
|
||||
import i18n from './i18n';
|
||||
import consts from './consts';
|
||||
import base64 from './base64';
|
||||
import themeColor from './theme-color';
|
||||
import tag from './tag';
|
||||
@ -8,7 +7,6 @@ import typescript from './typescript';
|
||||
|
||||
export default (lang, locale) => [
|
||||
i18n(lang, locale),
|
||||
consts(lang),
|
||||
base64(),
|
||||
themeColor(),
|
||||
tag(),
|
||||
|
37
webpack/plugins/consts.ts
Normal file
37
webpack/plugins/consts.ts
Normal file
@ -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)
|
||||
}));
|
||||
};
|
@ -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()
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user