Skip to content

Commit

Permalink
Merge pull request #337 from MuckRock/playwright-tests
Browse files Browse the repository at this point in the history
Namespace built assets to make caching easier
  • Loading branch information
eyeseast authored Nov 14, 2023
2 parents cc3b1a0 + 7871706 commit 6a12597
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public/node_modules_*
public/embed/*
public/notes/*
public/viewer/*
public/assets/

# Netlify
.netlify
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ browser-test-debug:

clean:
# delete Webpack chunks
rm -f public/[0-9]*.*.* public/bundle.*.js public/bundle.*.css public/bundle.*.txt
rm -f public/index.html public/[0-9]*.*.* public/bundle.*.js public/bundle.*.css public/bundle.*.txt public/*.map public/*.*.js
rm -rf public/assets public/notes public/viewer public/embed
4 changes: 0 additions & 4 deletions deploy-to-netlify.sh

This file was deleted.

7 changes: 2 additions & 5 deletions public/_headers
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# generated css and js files all have hashes in their names, so can be
# cached forever

/*.css
/assets/*.css
Cache-Control: public, max-age=604800, immutable

/*.js
/assets/*.js
Cache-Control: public, max-age=604800, immutable


Expand All @@ -16,6 +16,3 @@
/favicon.png
Cache-Control: public, max-age=86400, s-maxage=604800, immutable

/global.css
Cache-Control: public, max-age=86400, s-maxage=604800, immutable

1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ https://beta.documentcloud.org/* https://www.documentcloud.org/:splat 301!

/api/oembed.json https://api.www.documentcloud.org/api/oembed/
/documents/:id/:path https://api.www.documentcloud.org/files/documents/:id/:path
/assets/* /assets/:splat
/* /index.html 200
2 changes: 1 addition & 1 deletion src/common/Dropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
afterUpdate(() => {
if (active && name) {
plausible("dropdown", { props: { name } });
window.plausible && plausible("dropdown", { props: { name } });
}
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/app/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
(window.plausible.q = window.plausible.q || []).push(arguments);
};
plausible("pageview");
window.plausible && plausible("pageview");
hashRoute();
// debug
Expand Down
2 changes: 1 addition & 1 deletion src/pages/viewer/Viewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
if (!$viewer.embed) {
await initOrgsAndUsers();
plausible("pageview", { u: obscureURL() });
window.plausible && plausible("pageview", { u: obscureURL() });
}
});
Expand Down
5 changes: 3 additions & 2 deletions webpack.app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ const config = {
bundle: ["./src/main.js"],
},
output: {
path: __dirname + "/public",
filename: "[name].[chunkhash].js",
path: path.join(__dirname, "public"),
filename: "assets/[name].[chunkhash].js",
chunkFilename: "assets/[name].[chunkhash].js",
publicPath: "/",
},
plugins: [...baseConfig.plugins],
Expand Down
2 changes: 1 addition & 1 deletion webpack.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default wrap({
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
filename: "assets/[name].[contenthash].css",
}),
new DotEnv({
path: prod ? `.env.${environment}` : ".env",
Expand Down

0 comments on commit 6a12597

Please sign in to comment.