From ec8c010c546274f18eaa71c69c9a3092a163cda3 Mon Sep 17 00:00:00 2001 From: gumi Date: Mon, 12 Aug 2019 18:25:40 -0400 Subject: only use the compression plugins in production mode --- src/components/News.vue | 21 ++++++++++++++------- vue.config.js | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/News.vue b/src/components/News.vue index e3f9bde..7ad844f 100644 --- a/src/components/News.vue +++ b/src/components/News.vue @@ -53,14 +53,11 @@ } & .body { - margin-top: 1ex; + margin-top: 2ex; - & > br { - margin-bottom: 1em; - } - - & b { + &::v-deep > b { display: block; + margin-bottom: 1ex; } & :any-link { @@ -80,7 +77,7 @@ & q { color: #009000; - margin-top: 0.5em; + margin-top: 2ex; display: inline-block; &::before { @@ -115,9 +112,17 @@ export default class News extends Vue { @Prop({ default: 0 }) private from!: number; private entries: NewsEntry[] = (newsEntries as NewsEntry[]).slice(this.from, this.count); + beautify () { + this.entries.forEach(entry => { + // FIXME: weird Vue bug + entry.html = entry.html.replace(//g,"

"); + }); + } + mounted () { if (!process.env.VUE_APP_NEWS_JSON || !process.env.VUE_APP_NEWS_JSON.startsWith("https")) { // TODO: allow arbitrary paths (no hardcoded news.json) + this.beautify(); return; } @@ -127,6 +132,7 @@ export default class News extends Vue { if (newsCache !== null) { this.entries = (JSON.parse(newsCache) as NewsEntry[]).slice(this.from, this.count); + this.beautify(); } } @@ -139,6 +145,7 @@ export default class News extends Vue { .then(data => data.json()) .then(data => { this.entries = (data as NewsEntry[]).slice(this.from, this.count); + this.beautify(); if (Reflect.has(self, "localStorage")) { localStorage.setItem("newsCache", JSON.stringify(data)); diff --git a/vue.config.js b/vue.config.js index be8982d..c481b94 100644 --- a/vue.config.js +++ b/vue.config.js @@ -6,7 +6,7 @@ module.exports = { //integrity: true, // enable SRI in script/style tags parallel: true, configureWebpack: { - plugins: [ + plugins: process.env.NODE_ENV === "production" ? [ new CompressionPlugin({ filename: "[path].br[query]", algorithm: "brotliCompress", @@ -34,6 +34,6 @@ module.exports = { return zopfli.gzip(input, compressionOptions, callback); }, }), - ], + ]: [], } } -- cgit v1.2.3-60-g2f50