Skip to content

feat: support ipfs #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:10.15.1-browsers
environment:
NO_SANDBOX: true
steps:
- checkout
- run:
name: update-npm
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: install-npm
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: build-docs-ipfs
command: npm run docs:build:ipfs
- persist_to_workspace:
root: .
paths:
- ./docs/.vuepress/dist

deploy:
docker:
- image: olizilla/ipfs-dns-deploy:latest
environment:
DOMAIN: docs-beta.ipfs.io
BUILD_DIR: ./docs/.vuepress/dist
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Deploy website to IPFS
command: |
pin_name="$DOMAIN build $CIRCLE_BUILD_NUMBER"
hash=$(pin-to-cluster.sh "$pin_name" /tmp/workspace/$BUILD_DIR)
echo "Website added to IPFS: https://ipfs.io/ipfs/$hash"
# Update DNSlink for prod or dev domain
if [ "$CIRCLE_BRANCH" == "master" ] ; then
dnslink-dnsimple -d $DOMAIN -r _dnslink -l /ipfs/$hash
fi
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
context: ipfs-dns-deploy
requires:
- build
9 changes: 8 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,12 @@ module.exports = {
}
]
],
extraWatchFiles: ['.vuepress/nav/en.js']
extraWatchFiles: ['.vuepress/nav/en.js'],
configureWebpack: (config, isServer) => {
if (!isServer) {
config.entry = {
app: ['./docs/.vuepress/public-path.js', config.entry.app[0]]
}
}
}
}
12 changes: 12 additions & 0 deletions docs/.vuepress/public-path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

;(function() {
var ipfsPathRegExp = /^(\/(?:ipfs|ipns)\/[^/]+)/
var ipfsPathPrefix =
(window.location.pathname.match(ipfsPathRegExp) || [])[1] || ''

__webpack_public_path__ = ipfsPathPrefix + '/'
if (typeof window !== 'undefined') {
window.__VUEPRESS_ROUTER_BASE__ = ipfsPathPrefix + '/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! this var is the secret ingredient, where did you find it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vuepress bootstrap code.
but __webpack_public_path__ = ipfsPathPrefix + '/' this one is even more important without it the router would even load

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I knew there was a __webpack_public_path__ lurking about but I missed this one! Great work detective 🕵️‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah @satazor put me in the right direction with that one i just did the last mile

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the highest of fives to @satazor! It also makes me wonder if we could make a more generic IPFS plugin for webpack compiled apps using some of these framework config vars. we'd need to do detection for router logic but it doesn't seem impossible now... 🤔

Copy link

@satazor satazor Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I also thought about that in the past @cwaring and it’s doable. The route logic detection could also be pluggable, meaning we could have addons/plugins for typical frameworks such as Gatsby and Vue press.

I guess it would take some investment time but it would pay off later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, if we are delaying the adoption of origin isolation for a while then this might be a worthy endeavour to the community. I see this question crop up all the time.

}
})()
Loading