mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
18 lines
606 B
TypeScript
18 lines
606 B
TypeScript
import type { Plugin } from 'vite'
|
|
|
|
export const commentSourceMap = [
|
|
'// default boundary sourcemap with magic-string',
|
|
'//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHIn0=',
|
|
].join('\n')
|
|
|
|
export default function transformFooWithInlineSourceMap(): Plugin {
|
|
return {
|
|
name: 'transform-foo-with-inline-sourcemap',
|
|
transform(code, id) {
|
|
if (id.includes('foo-with-sourcemap.js')) {
|
|
return `${code}${commentSourceMap}`
|
|
}
|
|
},
|
|
}
|
|
}
|