From 5035f4cc98486c2e4b828e5ded0b90b7902a80f2 Mon Sep 17 00:00:00 2001 From: Danil Kovtonyuk Date: Thu, 28 Oct 2021 02:59:55 +1000 Subject: [PATCH] fix: ipfs --- app.html | 41 +++++++++++++++++++++++++++++++++++++++++ nuxt.config.js | 21 ++++++++++++++++++++- plugins/ipfs.js | 18 ++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 app.html create mode 100644 plugins/ipfs.js diff --git a/app.html b/app.html new file mode 100644 index 0000000..35a39a5 --- /dev/null +++ b/app.html @@ -0,0 +1,41 @@ + + + + + {{ HEAD }} + + + {{ APP }} + + diff --git a/nuxt.config.js b/nuxt.config.js index a0040ff..d5669d5 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -5,6 +5,10 @@ export default { // Target (https://go.nuxtjs.dev/config-target) target: 'static', + generate: { + fallback: true, + }, + // Global page headers (https://go.nuxtjs.dev/config-head) head: { title: 'Tornado.cash', @@ -37,7 +41,7 @@ export default { css: ['@/assets/styles/app.scss'], // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins) - plugins: ['~/plugins/i18n.js'], + plugins: ['~/plugins/i18n.js', '~/plugins/ipfs.js'], // Auto import components (https://go.nuxtjs.dev/config-components) components: true, @@ -88,6 +92,21 @@ export default { // splitChunks: { // commons: false // } + html: { + minify: { + collapseWhitespace: true, // as @dario30186 mentioned + removeComments: true, // 👈 add this line + }, + }, + loaders: { + fontUrl: { limit: 25000 }, + imgUrl: { limit: 15000 }, + }, + splitChunks: { + layouts: false, + pages: false, + commons: false, + }, }, router: { diff --git a/plugins/ipfs.js b/plugins/ipfs.js new file mode 100644 index 0000000..7a251e2 --- /dev/null +++ b/plugins/ipfs.js @@ -0,0 +1,18 @@ +/* eslint-disable camelcase, no-undef */ +export default (context, inject) => { + const ipfsPathRegExp = /^(\/(?:ipfs|ipns)\/[^/]+)/ + const ipfsPathPrefix = + (window.location.pathname.match(ipfsPathRegExp) || [])[1] || '' + + console.log('plugin __webpack_public_path__', __webpack_public_path__) + + if (ipfsPathPrefix) { + __webpack_public_path__ = ipfsPathPrefix + '/_nuxt/' + + if (typeof window !== 'undefined') { + context.app.router.history.base = ipfsPathPrefix || window.location.host + } + } + + console.log('plugin __webpack_public_path__', __webpack_public_path__) +}