Skip to content

Commit

Permalink
add react-router-dom cdn webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
lucia-gomez committed Mar 26, 2024
1 parent 0ce00f0 commit 9c538e2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions media_commons_booking_app/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
crossorigin="anonymous"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/1.8.1/datepicker.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/react-router-dom/6.22.3/react-router-dom.production.min.js"
integrity="sha512-eFKluaAyNJr8h7VL24su8w9qVFlNeLEI6nroW/ltJoh79cMIqXbHbJ+rKRZxalcTWiUPecOnSDnjVKsyAOA0xQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/react-router/6.22.3/react-router.production.min.js"
integrity="sha512-8GcWjbp4e2GeKa8Fz1Z3mqWvkiVrk6waiVdBG96PsOg30I9rjaOWDgD58A5umDn8KNs0OAxAYliKtX/r1mSy/A=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
</head>
<body>
<section id="index">
Expand Down
2 changes: 2 additions & 0 deletions media_commons_booking_app/src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import SelectRoomPage from './routes/booking/formPages/SelectRoomPage';
import UserRolePage from './routes/booking/formPages/UserRolePage';
import UserSectionPage from './routes/booking/formPages/UserSectionPage';

console.log('TEST IN INDEX.JS');

const router = createHashRouter([
{
path: '/',
Expand Down
16 changes: 15 additions & 1 deletion media_commons_booking_app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@ const DynamicCdnWebpackPluginConfig = {
version: packageVersion,
url: `https://unpkg.com/@types/react@${packageVersion}/index.d.ts`,
};
case 'react-router-dom':
return {
name: packageName,
var: 'ReactRouterDOM',
version: packageVersion,
url: `https://cdnjs.cloudflare.com/ajax/libs/react-router-dom/${packageVersion}/react-router-dom.production.min.js`,
};
case 'react-router':
return {
name: packageName,
var: 'ReactRouter',
version: packageVersion,
url: `https://cdnjs.cloudflare.com/ajax/libs/react-router/${packageVersion}/react-router.production.min.js`,
};
// return defaults/null depending if Dynamic CDN plugin finds package
default:
return moduleDetails;
Expand All @@ -267,7 +281,7 @@ const clientConfigs = clientEntrypoints.map((clientEntrypoint) => {
}),
new HtmlWebpackPlugin({
template: clientEntrypoint.template,
filename: `${clientEntrypoint.filename}.html`,
filename: `${clientEntrypoint.filename}${isProd ? '' : '-impl'}.html`,
inlineSource: '^/.*(js|css)$', // embed all js and css inline, exclude packages from dynamic cdn insertion
scriptLoading: 'blocking',
inject: 'body',
Expand Down

0 comments on commit 9c538e2

Please sign in to comment.