mirror of
https://github.com/tornadocash/tornado-initiation-ui.git
synced 2024-12-23 01:29:39 +01:00
fix: ipfs
This commit is contained in:
parent
58c65af18e
commit
5035f4cc98
41
app.html
Normal file
41
app.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html {{ HTML_ATTRS }}>
|
||||
<head {{ HEAD_ATTRS }}>
|
||||
<script>
|
||||
if (window.location.search) {
|
||||
console.log('redirect')
|
||||
window.location = window.location.origin + window.location.pathname
|
||||
}
|
||||
|
||||
function addScript(src) {
|
||||
const s = document.createElement('script')
|
||||
s.setAttribute('src', src)
|
||||
document.body.appendChild(s)
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const ipfsPathRegExp = /^(\/(?:ipfs|ipns)\/[^/]+)/
|
||||
const ipfsPathPrefix =
|
||||
(window.location.pathname.match(ipfsPathRegExp) || [])[1] || ''
|
||||
if (ipfsPathPrefix) {
|
||||
const scripts = [...document.getElementsByTagName('script')]
|
||||
|
||||
for (let i = 0; i < scripts.length; i++) {
|
||||
if (scripts[i].src) {
|
||||
const source = new URL(scripts[i].src)
|
||||
console.log('Loading', source.pathname)
|
||||
const newSource =
|
||||
window.location.origin + ipfsPathPrefix + source.pathname
|
||||
addScript(newSource)
|
||||
}
|
||||
}
|
||||
console.log('Finished')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{{ HEAD }}
|
||||
</head>
|
||||
<body {{ BODY_ATTRS }}>
|
||||
{{ APP }}
|
||||
</body>
|
||||
</html>
|
@ -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: {
|
||||
|
18
plugins/ipfs.js
Normal file
18
plugins/ipfs.js
Normal file
@ -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__)
|
||||
}
|
Loading…
Reference in New Issue
Block a user