Skip to content

Commit f0b47ec

Browse files
jhildenbiddlesy-records
authored andcommitted
Fix for Vercal “unsupported modules” error
1 parent 8f7f57f commit f0b47ec

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

middleware.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import serverConfigs from './server.configs.js';
2-
3-
const { rewriteRules } = serverConfigs.dev;
1+
import rewriteRules from './rewriterules.config.js';
42

53
// Exports
64
// =============================================================================

rewriterules.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default [
2+
// Replace CDN URLs with local paths
3+
{
4+
match: /https?.*\/CHANGELOG.md/g,
5+
replace: '/CHANGELOG.md',
6+
},
7+
{
8+
// CDN versioned default
9+
// Ex1: //cdn.com/package-name
10+
// Ex2: http://cdn.com/[email protected]
11+
// Ex3: https://cdn.com/package-name@latest
12+
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*(?=["'])/g,
13+
replace: '/lib/docsify.min.js',
14+
},
15+
{
16+
// CDN paths to local paths
17+
// Ex1: //cdn.com/package-name/path/file.js => /path/file.js
18+
// Ex2: http://cdn.com/[email protected]/dist/file.js => /dist/file.js
19+
// Ex3: https://cdn.com/package-name@latest/dist/file.js => /dist/file.js
20+
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*\/(?:lib\/)/g,
21+
replace: '/lib/',
22+
},
23+
];

0 commit comments

Comments
 (0)