vite/playground/js-sourcemap/foo-with-sourcemap-plugin.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
606 B
TypeScript
Raw Permalink Normal View History

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}`
}
},
}
}