Skip to content

Commit e7677a3

Browse files
committed
fix live reload on ract components
1 parent c2b0aff commit e7677a3

3 files changed

Lines changed: 97 additions & 36 deletions

File tree

gulpfile.babel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ function lint(files, options = {}) {
115115
return () => {
116116
return gulp
117117
.src(files)
118-
.pipe(reload({ stream: true, once: true }))
119118
.pipe($.eslint(options))
120119
.pipe($.eslint.format("compact"))
121120
.pipe($.if(!browserSync.active, $.eslint.failOnError()));
@@ -490,7 +489,9 @@ gulp.task(
490489
);
491490

492491
function reloadServer(done) {
493-
server.start.bind(server)();
492+
process.chdir(`${buildDir}`);
493+
server.start();
494+
process.chdir(`../`);
494495
done();
495496
}
496497

package-lock.json

Lines changed: 79 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/server.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,22 @@ import LibraryStorageService from "./app/services/LibraryDb.js";
1818
import LibraryActions from "./app/actions/LibraryActions";
1919

2020
let app = express();
21+
const isDevelopment = process.env.NODE_ENV === "development";
22+
const staticAssetOptions = isDevelopment
23+
? {
24+
maxAge: 0,
25+
etag: false,
26+
lastModified: false,
27+
setHeaders: (res) => {
28+
res.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate");
29+
res.setHeader("Pragma", "no-cache");
30+
res.setHeader("Expires", "0");
31+
},
32+
}
33+
: { maxage: "1d" };
2134

22-
app.use(express.static(path.join(__dirname, "public"), { maxage: "1d" }));
23-
app.use(express.static(path.join(__dirname, "views"), { maxage: "1d" }));
35+
app.use(express.static(path.join(__dirname, "public"), staticAssetOptions));
36+
app.use(express.static(path.join(__dirname, "views"), staticAssetOptions));
2437
app.use("/.well-known", express.static(".well-known"));
2538

2639
app.set("views", path.join(__dirname, "views"));

0 commit comments

Comments
 (0)