Open ZigaVukcevicDev opened 8 years ago
a) I have same issue with listenBeforeLeavingRoute
. No solution yet. // but in docs there is used old rc version 1.0.0 so maybe this is causing issues
b) as I understand, it's possible to use without this template - it only helps to render basic html (without react). As I understand it's probably used with templates loader (ejs-loader) configured in webpack so you can define basic html structure in nice way (but probably using es6 string notation is nice alternative some ${variable} inside
).
Edit: a) I had typo in routes declaration passed into match as first parameter - now this error is gone..
If anyone makes there way here, the issue for me was because I was using a redirect so essentially there wasn't a route for the path given to StaticSiteGenerateWebpackPlugin, so needed to handle the redirectLocation
when matching the route... something along the lines of
export default function(locals, callback) {
const history = createMemoryHistory();
const location = history.createLocation(locals.path);
function matchLocation(location) {
match({ routes, location }, (error, redirectLocation, renderProps) => {
if (redirectLocation) {
return matchLocation(redirectLocation);
}
callback(null, template({ ... }));
});
}
matchLocation(location);
})
Just an idea, but I wonder if the issue above is because the routes /hello/
or /world/
are slightly incorrect, because of trailing forward slash?
Hi,
thank you for the plugin. Although, I can not set it up, as
a) I am getting error in console
ERROR in TypeError: Cannot read property 'listenBeforeLeavingRoute' of undefined
b) Secondly, what should I write to
template.ejs
file?Please see my webpack.config.js content:
and my main.js file
and finally my package.json content
What am I doing wrong? I can provide more files, if necessary.