@@ -12,7 +12,7 @@ import { getHtmlScript } from '../utils/html'
1212
1313import type { PostcssOption } from '@tarojs/taro/types/compile'
1414import type { ViteH5CompilerContext } from '@tarojs/taro/types/compile/viteCompilerContext'
15- import type { PluginOption , ServerOptions } from 'vite'
15+ import type { PluginOption } from 'vite'
1616
1717
1818export default function ( viteCompilerContext : ViteH5CompilerContext ) : PluginOption {
@@ -93,9 +93,9 @@ export default function (viteCompilerContext: ViteH5CompilerContext): PluginOpti
9393 esnextModules : taroConfig . esnextModules || [ ]
9494 } )
9595 const [ , pxtransformOption ] = __postcssOption . find ( ( [ name ] ) => name === 'postcss-pxtransform' ) || [ ]
96- const serverOption : ServerOptions = ( taroConfig . devServer || { } ) as ServerOptions
97- let headers : Record < string , string | string [ ] > = { }
98- if ( isObject < Record < string , string | string [ ] > > ( serverOption . headers ) ) {
96+ const serverOption = taroConfig . devServer || { }
97+ let headers = { }
98+ if ( isObject < Record < string , any > > ( serverOption . headers ) ) {
9999 headers = serverOption . headers
100100 }
101101
@@ -164,6 +164,11 @@ export default function (viteCompilerContext: ViteH5CompilerContext): PluginOpti
164164 allowedHosts = [ serverOption . allowedHosts ]
165165 }
166166
167+ let sourcemapIgnoreList : false | ( ( sourcePath : string , sourcemapPath : string ) => boolean ) = ( sourcePath ) => sourcePath . includes ( 'node_modules' )
168+ if ( typeof serverOption . sourcemapIgnoreList === 'boolean' || typeof serverOption . sourcemapIgnoreList === 'function' ) {
169+ sourcemapIgnoreList = serverOption . sourcemapIgnoreList
170+ }
171+
167172 return {
168173 name : 'taro:vite-h5-config' ,
169174 enforce : 'pre' ,
@@ -238,7 +243,7 @@ export default function (viteCompilerContext: ViteH5CompilerContext): PluginOpti
238243 allowedHosts,
239244 middlewareMode,
240245 strictPort,
241-
246+ sourcemapIgnoreList ,
242247 origin,
243248 cors,
244249 } ,
0 commit comments