Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add log level option to wxt --debug mode #1942

Open
@honwhy

Description

add log level option to wxt --debug mode

I am using WXT Modules to port a website into Chrome extension as running the website in Chrome extension options.

In dev mode, my wxt modules use addViteConfig to add vite plugin to support virtual scripts. ex, in htmlScriptToVirtual plugin use config.logger.info and config.logger.debug two log functions. I would like wxt --debug command to add log level support, so that in dev mode only log the config.logger.info content.

 addViteConfig(wxt, () => ({
 plugins: [
 htmlScriptToVirtual(wxt.config, () => wxt.server),
 vueDevtoolsHack(wxt.config, () => wxt.server),
 wxt.config.command === `build`
 ? htmlScriptToLocal(wxt)
 : undefined,
 ],
 }))

Is your feature request related to a bug?

"N/A"

What are the alternatives?

comment out the config.logger.debug lines, only keep the config.logger.info lines.

Additional context

codes,

{
 name: `md:dev-html-prerender`,
 apply: `build`,
 transformIndexHtml: {
 order: `post`,
 async handler(html) {
 if (server == null) {
 return html
 }
 const { document } = parseHTML(html)
 // Replace inline script with virtual module served via dev server.
 // Extension CSP blocks inline scripts, so that's why we're pulling them out.
 const promises: Promise<void>[] = []
 const inlineScripts = document.querySelectorAll(`script[src^=http]`)
 inlineScripts.forEach(async (script) => {
 promises.push(new Promise<void>((resolve) => {
 const url = script.getAttribute(`src`) ?? ``
 if (url?.startsWith(`http://localhost`)) {
 resolve()
 return
 }
 doFetch(url).then((textContent) => {
 const key = hash(textContent)
 inlineScriptContents[key] = textContent
 config.logger.info(`key-content`, key, textContent.slice(0, 10))
 script.setAttribute(`src`, `${server.origin}/@id/${virtualInlineScript}?${key}`)
 if (script.hasAttribute(`id`)) {
 script.setAttribute(`type`, `module`)
 }
 resolve()
 })
 }))
 })
 await Promise.all(promises)
 const newHtml = document.toString()
 config.logger.debug(`\nhtmlScriptToVirtual Old HTML:\n${html}`)
 config.logger.debug(`\nhtmlScriptToVirtual New HTML:\n${newHtml}`)
 return newHtml
 },
 },
 },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /