Comments (4)
No, unfortunately. As mentioned in the README:
Only works with routing strategies using the HTML5 history API.
from prerender-spa-plugin.
I am running into a similiar issue. I am using Vue.js on S3.
We want the following paths:
/
/somepath/sad
/about
/somepath/ads.html
The current code in index.js creates folders for a url and then a file named index.html. Unfortunately S3 forces redirects that causes /about to become /about/ in this case.
I have made a small change to index.js that enables us to have paths like this, I believe this is what @KenCorbettJr is trying to archive as well.
This code
var folder = Path.join(self.staticDir, outputPath)
mkdirp(folder, function (error) {
if (error) {
return reject('Folder could not be created: ' + folder + '\n' + error)
}
var file = Path.join(folder, 'index.html')
FS.writeFile(
file,
prerenderedHTML,
function (error) {
if (error) {
return reject('Could not write file: ' + file + '\n' + error)
}
resolve()
}
)
})
Becomes
var folder = Path.join(self.staticDir, outputPath.substr(0, outputPath.lastIndexOf("/")))
var file = Path.join(folder, outputPath.substr(outputPath.lastIndexOf("/"), outputPath.length))
if ('/' === outputPath.charAt(outputPath.length-1)) {
file = Path.join(file, 'index.html')
}
function writeHTML() {
FS.writeFile(
file,
prerenderedHTML,
function (error) {
if (error) {
return reject('Could not write file: ' + file + '\n' + error)
}
resolve()
}
)
}
if (file !== folder)
{
mkdirp(folder, function (error) {
if (error) {
return reject('Folder could not be created: ' + folder + '\n' + error)
}
writeHTML()
})
}
else {
writeHTML()
}
If desired I can create a pull request with the code changes to enable this
from prerender-spa-plugin.
Thanks @heinzdmx for this snippet. At the very least I can add this to my own fork. You make a good point about the challenges in hosting this on S3. This library makes some assumptions about url rewrite rules that don't always apply. There may be instances where people have even changed their DirectoryIndex so that it serves a file with a different name other than index.html file when a request comes in to the folder. If that is the case this library would completely fail.
Even though it is an edge case, it would be nice if support was added to the library so that we wouldn't have to maintain our own fork, constantly merging in new code. It is a common enough use case that I think it makes sense. At the very least it gives this plugin the flexibility to work even when the hosting environment doesn't match the assumptions that were made. I think the current behavior is perfectly fine default, but it would be nice to have more options.
from prerender-spa-plugin.
@chrisvfritz
Would you mind taking a look at my comment, to see if that is something you would be willing to add support for?
from prerender-spa-plugin.
Related Issues (20)
- Plugin creates broken HTML HOT 1
- Puppeteer Issues on Oracle Linux 8 HOT 2
- Optimization of Puppeteer
- I have a Vue multi-page app, after prerender, all html files look the same. HOT 1
- render each route to an html file
- Only two pages are getting pre-rendered properly
- How to cache the result.
- docker
- on Safari and ios it doesn't always work
- [prerender-spa-plugin] Unable to prerender all routes! HOT 4
- How to configure puppeteer inside prerender-spa for Heroku
- How to launch puppeteer with { args: ['--no-sandbox'] }?
- "/" page flashing before routes load
- Unexpected token '?' with plugin only HOT 2
- Looking for maintainers! HOT 15
- Error during building example app: probably smth with websocket errno: -4039, code: 'ETIMEDOUT'
- Vue Prerender-SPA / Webpack - Application won't initialise with named cacheGroups unless explicitly listed in pages config chunks section?
- why no such file or directory
- Unable to prerender all routes! HOT 2
- Page refresh twice
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prerender-spa-plugin.