File tree Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Original file line number Diff line number Diff line change 11import type * as esbuild from '@esbuild' ;
22
33
4- const defaultExtensionReplacements = {
5- '.tsx' : '.js' ,
6- '.ts' : '.js'
7- }
8-
94export function htmlScriptTags ( options ?: {
105 pattern ?: RegExp ,
11- extension ?: { [ extension : string ] : string }
6+ replaceExtensionWith ?: string
127} ) : esbuild . Plugin {
138 return ( {
149 name : 'html-script-tags' ,
@@ -18,16 +13,7 @@ export function htmlScriptTags(options?: {
1813 contents : Deno . readTextFileSync ( args . path ) . replace (
1914 options ?. pattern ?? / (?< = < s c r i p t .* s r c = " ) ( .* ) (? = " .* > ) / gm,
2015 ( _ , scriptSrcPath : string ) => {
21- let path = scriptSrcPath ;
22- let replaced = false ;
23- Object . entries ( options ?. extension ?? defaultExtensionReplacements ) . forEach ( ( [ extension , replacement ] ) => {
24- if ( scriptSrcPath . match ( extension ) && ! replaced ) {
25- path = scriptSrcPath . replace ( extension , replacement )
26- replaced = true
27- }
28- } )
29-
30- return path ;
16+ return scriptSrcPath . replace ( / \. t s x ? $ / , options ?. replaceExtensionWith ?? '.js' )
3117 }
3218 ) ,
3319 loader : 'copy' ,
You can’t perform that action at this time.
0 commit comments