mirror of
https://github.com/elk-zone/elk
synced 2024-11-23 22:56:09 +09:00
45b6e39b6e
resolves 'Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.'
29 lines
652 B
TypeScript
29 lines
652 B
TypeScript
import { addVitePlugin, defineNuxtModule } from '@nuxt/kit'
|
|
import MagicString from 'magic-string'
|
|
|
|
export default defineNuxtModule({
|
|
meta: {
|
|
name: 'purge-comments',
|
|
},
|
|
setup() {
|
|
addVitePlugin({
|
|
name: 'purge-comments',
|
|
enforce: 'pre',
|
|
transform: (code, id) => {
|
|
if (!id.endsWith('.vue') || !code.includes('<!--'))
|
|
return
|
|
|
|
const s = new MagicString(code)
|
|
s.replace(/<!--(?:.*?)-->/sg, '')
|
|
|
|
if (s.hasChanged()) {
|
|
return {
|
|
code: s.toString(),
|
|
map: s.generateMap({ source: id, includeContent: true }),
|
|
}
|
|
}
|
|
},
|
|
})
|
|
},
|
|
})
|