问题
Here's what the livereload block looks like in Grunt file:
livereload: {
options: {
open: true,
middleware: function(connect, options, middleware) {
var optBase = typeof options.base === "string"
? [options.base]
: options.base;
return [
[
require("connect-modrewrite")(["!(\\..+)$ / [L]"])
].concat(
optBase.map(function(path) { return connect.static(path); })
),
connect.static(".tmp"),
connect().use("/bower_components", connect.static("./bower_components")),
connect().use("/app/styles", connect.static("./app/styles")),
connect.static(appConfig.app)
];
}
}
}
However, if my URL has a '.' (period) in it, Grunt fails to reload the page. I am using HTML5 Mode in my Angular app and that works fine.
Could I please know what part of
[
require("connect-modrewrite")(["!(\\..+)$ / [L]"])
].concat(
optBase.map(function (path) { return connect.static(path); })
)
is causing it to fail and how do I fix this?
Note: It fails only on page reload. The first time I visit the route it works, then if I hit refresh it fails.
来源:https://stackoverflow.com/questions/47493760/grunt-url-rewrite-in-angular-application-on-page-reload