Skip to content

Commit

Permalink
fix(viteroll): handle any script src
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 9, 2024
1 parent f950271 commit 2a2b4ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion viteroll/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</head>
<body>
<div id="root"></div>
<script src="./src/index.ts"></script>
<script type="module" src="./src/index.ts"></script>
</body>
</html>
4 changes: 3 additions & 1 deletion viteroll/viteroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ function viterollEntryPlugin(
}

// extract <script src="...">
const matches = code.matchAll(/<script\s+src="([^"]+)"><\/script>/dg);
const matches = code.matchAll(
/<script\b[^>]+\bsrc=["']([^"']+)["'][^>]*>.*?<\/script>/dg,
);
for (const match of matches) {
const src = match[1];
const resolved = await this.resolve(src, id);
Expand Down

0 comments on commit 2a2b4ae

Please sign in to comment.