PlasmoHQ / plasmo

šŸ§© The Browser Extension Framework
https://www.plasmo.com
MIT License
10.14k stars 350 forks source link

[BUG] Icon Assets not found after 0.84 update #825

Open MentalGear opened 9 months ago

MentalGear commented 9 months ago

What happened?

After updating from 83 to 84, the build process errors out due to:

šŸ”“ ERROR  | Failed to resolve './gen-assets/icon16.plasmo.png' from './.plasmo/chrome-mv3.plasmo.manifest.json'
šŸ”“ ERROR  | Cannot load file './gen-assets/icon16.plasmo.png' in './.plasmo'.

šŸ”“ ERROR  | Cannot load file './gen-assets/icon32.plasmo.png' in './.plasmo'.
šŸŸ” 22     | Did you mean '__../src/assets/icon.png__'?

Even after deleting .plasmo, the same error occurs.

Looking at .plasmo, there is no gen-assets folder, which seems like the folder is not generated before it is tried to access.

Version

Latest

What OS are you seeing the problem on?

MacOSX

What browsers are you seeing the problem on?

Chrome, Firefox

Relevant log output

šŸ”“ ERROR  | Failed to resolve './gen-assets/icon16.plasmo.png' from './.plasmo/chrome-mv3.plasmo.manifest.json'
šŸ”“ ERROR  | Cannot load file './gen-assets/icon16.plasmo.png' in './.plasmo'.

šŸ”“ ERROR  | Cannot load file './gen-assets/icon32.plasmo.png' in './.plasmo'.
šŸŸ” 22     | Did you mean '__../src/assets/icon.png__'?

(OPTIONAL) Contribution

Code of Conduct

MentalGear commented 9 months ago

Even after downgrading to 0.83 the issue persists. I was able to temporarily skip this build error by manually adding .pngs into .plasmo/gen-assets with the icon files specified in /.plasmo/chrome-mv3.plasmo.manifest.json. However, still waiting on an official fix/explanation.

louisgv commented 9 months ago

Hmm that's very weird... All the E2E build test passed meaning they were able to resolve the icons: https://github.com/PlasmoHQ/plasmo/actions/runs/6822430999/job/18554456871

Can you post the full output of plasmo dev --verbose?

MentalGear commented 9 months ago

Thanks for the quick feedback. I changed my source directory from root to /src a while ago (2 weeks), but hadn't had any issue with it yet. Also, I use type: module.

šŸ”“ ERROR | Failed to resolve './gen-assets/icon16.plasmo.png' from './.plasmo/chrome-mv3.plasmo.manifest.json' šŸŸ” 22 |

{
  "icons": {
    "16": "./gen-assets/icon16.plasmo.png",
    "32": "./gen-assets/icon32.plasmo.png",
    "48": "./gen-assets/icon48.plasmo.png",
    "64": "./gen-assets/icon64.plasmo.png",
    "128": "./gen-assets/icon128.plasmo.png"
  },
  "manifest_version": 3,
  "action": {
    "default_icon": {
      "16": "./gen-assets/icon16.plasmo.png",
      "32": "./gen-assets/icon32.plasmo.png",
      "48": "./gen-assets/icon48.plasmo.png",
      "64": "./gen-assets/icon64.plasmo.png",
      "128": "./gen-assets/icon128.plasmo.png"
    },
    "default_popup": "./popup.html"
  },
  "background": {
    "service_worker": "./static/background/index.ts"
  },
  "chrome_url_overrides": {
    "newtab": "./newtab.html"
  },
  "permissions": [
    "scripting",
    "tabs"
  ],
  "content_scripts": [
    {
      "matches": [
        "https://www.plasmo.com/*"
      ],
      "js": [
        "static/contents/plasmo-inline.ts"
      ]
    }
  ],
  "content_security_policy": {
    "extension_pages": "script-src 'self' 'wasm-unsafe-eval'"
  },
  "host_permissions": [
    "https://*/*"
  ],
  "web_accessible_resources": [
    {
      "resources": [
        "assets/local-models/**/*"
      ],
      "extension_ids": [
        "*"
      ],
      "matches": [
        "https://*/*",
        "*://*/*",
        "<all_urls>"
      ]
    },
    {
      "resources": [
        "assets/example"
      ],
      "matches": [
        "https://*/*",
        "*://*/*",
        "<all_urls>"
      ]
    }
  ]
}

šŸŸ” 23 | /Users/.../.plasmo/chrome-mv3.plasmo.manifest.json:12:13 šŸ”“ ERROR | Cannot load file './gen-assets/icon16.plasmo.png' in './.plasmo'. šŸŸ” 24 | Did you mean '../src/assets/icon.png'

MentalGear commented 9 months ago

I am also getting WARN | No icon found in assets directory on plasmo start-up.

šŸŸ£ Plasmo v0.84.0
šŸ”“ The Browser Extension Framework
šŸ”µ INFO   | Starting the extension development server...
šŸŸ  WARN   | No icon found in assets directory

Yet there is an icon.png in /src/assets

wfk007 commented 8 months ago

I encountered the same error when getting started with pnpm create plasmo.

  1. pnpm create plasmo: plasmo@0.84.0 in packag.json and node_modules
  2. move all source code files into the src directory including assets folder
  3. update compilerOptions.paths in tsconfig.json
  4. pnpm run dev
wfk007 commented 8 months ago

@MentalGear It worked for me when I move the assets directory out of the src directory.

https://github.com/PlasmoHQ/plasmo/blob/00fb828df6298beb480783c941b4c970811e46c3/cli/plasmo/src/features/extension-devtools/common-path.ts#L47

MentalGear commented 8 months ago

Seems to be a definite problem from switching to /src later on. I am still experiencing the error and occasionally have to manually add the gen-assets folder into the .plasmo folder again or it won't compile.

Thx for the input. Do you mean rewriting the assetsDirectory: resolve(projectDirectory, "assets"), line and manually moving the folder out of assets?

On 28 Dec 2023, at 09:43, fukang wang @.***> wrote:

I encountered the same error when getting started with pnpm create plasmo.

pnpm create plasmo: @.*** in packag.json and node_modules move all source code files into the src directory including assets folder update compilerOptions.paths in tsconfig.json pnpm run dev ā€” Reply to this email directly, view it on GitHub https://github.com/PlasmoHQ/plasmo/issues/825#issuecomment-1870946472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVUVG6MJSNIIWHHGXAICHDYLUWL3AVCNFSM6AAAAAA7UMM7QOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQHE2DMNBXGI. You are receiving this because you authored the thread.

wfk007 commented 8 months ago

Seems to be a definite problem from switching to /src later on. I am still experiencing the error and occasionally have to manually add the gen-assets folder into the .plasmo folder again or it won't compile. Thx for the input. Do you mean rewriting the assetsDirectory: resolve(projectDirectory, "assets"), line and manually moving the folder out of assets? ā€¦ On 28 Dec 2023, at 09:43, fukang wang @.> wrote: I encountered the same error when getting started with pnpm create plasmo. pnpm create plasmo: @. in packag.json and node_modules move all source code files into the src directory including assets folder update compilerOptions.paths in tsconfig.json pnpm run dev ā€” Reply to this email directly, view it on GitHub <#825 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVUVG6MJSNIIWHHGXAICHDYLUWL3AVCNFSM6AAAAAA7UMM7QOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQHE2DMNBXGI. You are receiving this because you authored the thread.

Try to move assets from src to projectDirectory directory

aiddroid commented 7 months ago

There's a weird solution, I add .plasmo directory to git to avoid the unexpected configuration files lost.

MentalGear commented 7 months ago

Try to move assets from src to projectDirectory directory

That worked for me!

stevebeauge commented 5 months ago

I'm facing the same issue.

I have both src and assets as sibling in the root of the repo. However, when building, plasmo (v85.2) tries to get the icon inside the src folder:

šŸ”“ ERROR  | ENOENT: no such file or directory, stat 'C:\\path\my-extension\\src\\assets\\icon.png'

If I move the asset folder inside the src folder, I fall into the issue described above.

What did I miss?