summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-15 12:56:50 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-15 12:56:50 +0900
commit45cb5cec04e4e6eb968bc4d1b54e8daf54b404ae (patch)
tree8d6ea96e0189c2cfaa677b8cadb4597e5e1b8d81
parentoops (diff)
downloadsharkey-45cb5cec04e4e6eb968bc4d1b54e8daf54b404ae.tar.gz
sharkey-45cb5cec04e4e6eb968bc4d1b54e8daf54b404ae.tar.bz2
sharkey-45cb5cec04e4e6eb968bc4d1b54e8daf54b404ae.zip
#1239
-rw-r--r--package.json1
-rw-r--r--src/web/app/boot.js6
-rw-r--r--src/web/app/desktop/views/components/settings.vue11
-rw-r--r--src/web/assets/404.js2
-rw-r--r--webpack.config.ts27
5 files changed, 34 insertions, 13 deletions
diff --git a/package.json b/package.json
index 27af69a4c5..c75e0e111a 100644
--- a/package.json
+++ b/package.json
@@ -184,7 +184,6 @@
"typescript": "2.7.2",
"typescript-eslint-parser": "14.0.0",
"uglify-es": "3.3.9",
- "uglifyjs-webpack-plugin": "1.2.3",
"url-loader": "1.0.1",
"uuid": "3.2.1",
"v-animate-css": "0.0.2",
diff --git a/src/web/app/boot.js b/src/web/app/boot.js
index 2d2e27df30..41685aadca 100644
--- a/src/web/app/boot.js
+++ b/src/web/app/boot.js
@@ -62,13 +62,17 @@
app = isMobile ? 'mobile' : 'desktop';
}
+ // Script version
const ver = localStorage.getItem('v') || VERSION;
+ // Whether use raw version script
+ const raw = localStorage.getItem('useRawScript') == 'true';
+
// Load an app script
// Note: 'async' make it possible to load the script asyncly.
// 'defer' make it possible to run the script when the dom loaded.
const script = document.createElement('script');
- script.setAttribute('src', `/assets/${app}.${ver}.${lang}.js`);
+ script.setAttribute('src', `/assets/${app}.${ver}.${lang}.${raw ? 'raw' : 'min'}.js`);
script.setAttribute('async', 'true');
script.setAttribute('defer', 'true');
head.appendChild(script);
diff --git a/src/web/app/desktop/views/components/settings.vue b/src/web/app/desktop/views/components/settings.vue
index 39d9be01da..5627da1ccc 100644
--- a/src/web/app/desktop/views/components/settings.vue
+++ b/src/web/app/desktop/views/components/settings.vue
@@ -160,10 +160,13 @@
<section class="other" v-show="page == 'other'">
<h1>高度な設定</h1>
<mk-switch v-model="debug" text="デバッグモードを有効にする">
- <span>この設定はアカウントに保存されません。</span>
+ <span>この設定はブラウザに記憶されます。</span>
</mk-switch>
<mk-switch v-model="enableExperimental" text="実験的機能を有効にする">
- <span>この設定はアカウントに保存されません。実験的機能を有効にするとMisskeyの動作が不安定になる可能性があります。</span>
+ <span>実験的機能を有効にするとMisskeyの動作が不安定になる可能性があります。この設定はブラウザに記憶されます。</span>
+ </mk-switch>
+ <mk-switch v-model="useRawScript" text="生のスクリプトを読み込む">
+ <span>圧縮されていない「生の」スクリプトを使用します。サイズが大きいため、読み込みに時間がかかる場合があります。この設定はブラウザに記憶されます。</span>
</mk-switch>
</section>
@@ -214,6 +217,7 @@ export default Vue.extend({
lang: localStorage.getItem('lang') || '',
preventUpdate: localStorage.getItem('preventUpdate') == 'true',
debug: localStorage.getItem('debug') == 'true',
+ useRawScript: localStorage.getItem('useRawScript') == 'true',
enableExperimental: localStorage.getItem('enableExperimental') == 'true'
};
},
@@ -236,6 +240,9 @@ export default Vue.extend({
debug() {
localStorage.setItem('debug', this.debug ? 'true' : 'false');
},
+ useRawScript() {
+ localStorage.setItem('useRawScript', this.useRawScript ? 'true' : 'false');
+ },
enableExperimental() {
localStorage.setItem('enableExperimental', this.enableExperimental ? 'true' : 'false');
}
diff --git a/src/web/assets/404.js b/src/web/assets/404.js
index 285704d113..f897f0db6b 100644
--- a/src/web/assets/404.js
+++ b/src/web/assets/404.js
@@ -13,6 +13,8 @@ if (yn) {
console.error(e);
}
+ localStorage.removeItem('v');
+
location.reload(true);
} else {
alert('問題が解決しない場合はサーバー管理者までお問い合せください。');
diff --git a/webpack.config.ts b/webpack.config.ts
index e3684f9d89..0fb63499c5 100644
--- a/webpack.config.ts
+++ b/webpack.config.ts
@@ -6,7 +6,7 @@ import * as fs from 'fs';
import * as webpack from 'webpack';
import chalk from 'chalk';
import jsonImporter from 'node-sass-json-importer';
-const minify = require('html-minifier').minify;
+const minifyHtml = require('html-minifier').minify;
const WebpackOnBuildPlugin = require('on-build-webpack');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
@@ -17,7 +17,7 @@ const constants = require('./src/const.json');
import config from './src/conf';
import { licenseHtml } from './src/common/build/license';
-import langs from './locales';
+import locales from './locales';
const meta = require('./package.json');
const version = meta.version;
@@ -28,7 +28,7 @@ const isProduction = env === 'production';
global['faReplacement'] = faReplacement;
global['collapseSpacesReplacement'] = html => {
- return minify(html, {
+ return minifyHtml(html, {
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
keepClosingSlash: true
@@ -40,7 +40,14 @@ global['base64replacement'] = (_, key) => {
};
//#endregion
-module.exports = Object.keys(langs).map(lang => {
+const langs = Object.keys(locales);
+
+let entries = langs.map(l => [l, false]);
+entries = entries.concat(langs.map(l => [l, true]));
+
+module.exports = entries.map(x => {
+ const [lang, doMinify] = x;
+
// Chunk name
const name = lang;
@@ -58,10 +65,10 @@ module.exports = Object.keys(langs).map(lang => {
const output = {
path: __dirname + '/built/web/assets',
- filename: `[name].${version}.${lang}.js`
+ filename: `[name].${version}.${lang}.${doMinify ? 'min' : 'raw'}.js`
};
- const i18nReplacer = new I18nReplacer(lang);
+ const i18nReplacer = new I18nReplacer(lang as string);
global['i18nReplacement'] = i18nReplacer.replacement;
//#region Define consts
@@ -110,9 +117,8 @@ module.exports = Object.keys(langs).map(lang => {
})
];
- if (isProduction) {
+ if (doMinify) {
plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
- plugins.push(minify());
}
return {
@@ -235,6 +241,9 @@ module.exports = Object.keys(langs).map(lang => {
modules: ['node_modules', './webpack/loaders']
},
cache: true,
- devtool: 'source-map'
+ devtool: 'source-map',
+ optimization: {
+ minimize: doMinify
+ }
};
});