Skip to content

Commit

Permalink
build: include hash in webpack chunk filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
barnslig committed Feb 6, 2022
1 parent aa9b399 commit 78dceab
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* tslint:disable */

/**
* Mock Service Worker (0.36.3).
* Mock Service Worker (0.36.8).
* @see https://github.com/mswjs/msw
* - Please do NOT modify this file.
* - Please do NOT serve this file on production.
Expand Down
20 changes: 15 additions & 5 deletions app/src/app/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ const lazyWithPreload = <T extends React.ComponentType<any>>(
factory,
});

const CodePage = lazyWithPreload(() => import("./pages/CodePage"));
const IndexPage = lazyWithPreload(() => import("./pages/IndexPage"));
const MessagesPage = lazyWithPreload(() => import("./pages/MessagesPage"));
const ScannerPage = lazyWithPreload(() => import("./pages/ScannerPage"));
const StartPage = lazyWithPreload(() => import("./pages/StartPage"));
const CodePage = lazyWithPreload(
() => import(/* webpackChunkName: "CodePage" */ "./pages/CodePage")
);
const IndexPage = lazyWithPreload(
() => import(/* webpackChunkName: "IndexPage" */ "./pages/IndexPage")
);
const MessagesPage = lazyWithPreload(
() => import(/* webpackChunkName: "MessagesPage" */ "./pages/MessagesPage")
);
const ScannerPage = lazyWithPreload(
() => import(/* webpackChunkName: "ScannerPage" */ "./pages/ScannerPage")
);
const StartPage = lazyWithPreload(
() => import(/* webpackChunkName: "StartPage" */ "./pages/StartPage")
);

const routeFactories = [
{
Expand Down
4 changes: 3 additions & 1 deletion app/src/common/components/QRCodeReader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const QRCodeReader = ({ torch = false, onResult }: QRCodeReaderProps) => {
}

// The zxing library is HUGE, thus we load it asynchronously
const { BrowserQRCodeReader } = await import("@zxing/browser");
const { BrowserQRCodeReader } = await import(
/* webpackChunkName: "zxing" */ "@zxing/browser"
);

const codeReader = new BrowserQRCodeReader();
controls.current = await codeReader.decodeFromVideoElement(
Expand Down
4 changes: 3 additions & 1 deletion app/src/common/components/QrCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const QrCode = ({ contents, width = 300, height = 300 }: QrCodeProps) => {
React.useEffect(() => {
(async () => {
if (!writer.current) {
const { BrowserQRCodeSvgWriter } = await import("@zxing/browser");
const { BrowserQRCodeSvgWriter } = await import(
/* webpackChunkName: "zxing" */ "@zxing/browser"
);
writer.current = new BrowserQRCodeSvgWriter();
}

Expand Down
2 changes: 2 additions & 0 deletions app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = {
output: {
clean: true,
publicPath: "/",
chunkFilename: "javascripts/chunks/[chunkhash].[name].js",
filename: "javascripts/[contenthash].[name].js",
},
module: {
rules: [
Expand Down

0 comments on commit 78dceab

Please sign in to comment.