Skip to content

Commit

Permalink
Tem fix for Vercal “unsupported modules:” error
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle committed Dec 21, 2023
1 parent c098ffa commit fbeab47
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions middleware.js
@@ -1,6 +1,26 @@
import serverConfigs from './server.config.js';

const { rewriteRules } = serverConfigs.dev;
const rewriteRules = [
// Replace CDN URLs with local paths
{
match: /https?.*\/CHANGELOG.md/g,
replace: '/CHANGELOG.md',
},
{
// CDN versioned default
// Ex1: //cdn.com/package-name
// Ex2: http://cdn.com/package-name@1.0.0
// Ex3: https://cdn.com/package-name@latest
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*(?=["'])/g,
replace: '/lib/docsify.min.js',
},
{
// CDN paths to local paths
// Ex1: //cdn.com/package-name/path/file.js => /path/file.js
// Ex2: http://cdn.com/package-name@1.0.0/dist/file.js => /dist/file.js
// Ex3: https://cdn.com/package-name@latest/dist/file.js => /dist/file.js
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*\/(?:lib\/)/g,
replace: '/lib/',
},
];

// Exports
// =============================================================================
Expand Down

0 comments on commit fbeab47

Please sign in to comment.