From d9a23fbb08c84cb7dd72fceb6568028430aa530f Mon Sep 17 00:00:00 2001 From: beesperester Date: Fri, 13 Apr 2018 12:29:57 +0200 Subject: [PATCH 1/2] substitute history with custom history eg: createBrowserHistory --- build/index.html | 2 +- example/app.html | 5 ++++- {src/utils => example}/history.js | 2 +- rollup.config.js | 1 + src/components/RouterLink.html | 3 +-- src/utils/create-router.js | 10 ++++++++-- 6 files changed, 16 insertions(+), 7 deletions(-) rename {src/utils => example}/history.js (50%) diff --git a/build/index.html b/build/index.html index 1a5d163..8b88c1e 100644 --- a/build/index.html +++ b/build/index.html @@ -10,6 +10,6 @@
- + diff --git a/example/app.html b/example/app.html index a6ffe44..3ce13f9 100644 --- a/example/app.html +++ b/example/app.html @@ -15,6 +15,9 @@ import Hello from './Hello.html' import NotFound from './NotFound.html' + // import custom (browser) history + import history from './history' + const { createRouter, RouterLink } = SvelteRouter const store = new Store({ @@ -39,7 +42,7 @@ }, }, default: NotFound - }) + }, history) createRouter.listen(() => { console.log('router changed') }) diff --git a/src/utils/history.js b/example/history.js similarity index 50% rename from src/utils/history.js rename to example/history.js index b30cb25..1109eca 100644 --- a/src/utils/history.js +++ b/example/history.js @@ -1,4 +1,4 @@ -import createHistory from 'history/createHashHistory' +import createHistory from 'history/createBrowserHistory' const history = createHistory() diff --git a/rollup.config.js b/rollup.config.js index 404b38a..96877b9 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -45,6 +45,7 @@ if (process.env.NODE_ENV === 'production') { config.input = './example/main.js' config.plugins.unshift( serve({ + historyApiFallback: true, contentBase: ['lib', 'build'] }), livereload('release') diff --git a/src/components/RouterLink.html b/src/components/RouterLink.html index 8595e5a..fe0225b 100644 --- a/src/components/RouterLink.html +++ b/src/components/RouterLink.html @@ -3,7 +3,6 @@