Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

打包时生成manifest.json中的default_popup的地址也许可以优化 #33

Open
Llyonss opened this issue Oct 28, 2023 · 1 comment

Comments

@Llyonss
Copy link

Llyonss commented Oct 28, 2023

背景

我的目录层级如下:

  • src
    • crx
      • popup
        • index.html
      • manifest.json
        其中manifest代码如下:
{
   ... 
   "action": {
    "default_popup": "./popup/index.html"
    },
   ...
}

问题

此时生成的dist的目录如下,符合预期:

  • src
    • crx
      • popup
        • index.html
  • manifest.json

但是dist中生成的 manifest.json代码如下,不符合预期:

{
   ... 
   "action": {
    "default_popup": "index.html"
    },
   ...
}

期望

期望生成如下路径

{
   ... 
   "action": {
    "default_popup": "./src/crx/popup/index.html"
    },
   ...
}

分析

阅读源码时发现问题来源自下方 src/processors/manifest.ts 中的 generateManifest 函数的代码:

...
generateManifest (){
   ...
    if (manifest.action?.default_popup) {
      manifest.action.default_popup = basename(manifest.action.default_popup)
    }
   ...
}
...

如果可以的话,希望其中使用 basename() 函数生成 popup 这里可以加一点适配不同的目录结构的逻辑,比如:

...
generateManifest (){
   ...
    if (manifest.action?.default_popup) {
      manifest.action.default_popup = manifest.action.default_popup.replace( /^\./, this.srcDir);
    }
   ...
}
...

或者把popup的index.html文件生成到根目录。

@Llyonss Llyonss changed the title 打包时生成manifest.json中的default_popup的地址不符合预期 打包时生成manifest.json中的default_popup的地址也许可以优化 Oct 28, 2023
@Jervis2049
Copy link
Owner

感谢你提出的问题。不过现阶段比较忙,无力维护☹️,短期无法提供方案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants