Coder Social home page Coder Social logo

When my plugin opens a local html page, it can't find the js file in the same directory as the page? about vite-vue3-chrome-extension-v3 HOT 7 CLOSED

mubaidr avatar mubaidr commented on June 20, 2024
When my plugin opens a local html page, it can't find the js file in the same directory as the page?

from vite-vue3-chrome-extension-v3.

Comments (7)

mubaidr avatar mubaidr commented on June 20, 2024

Opening local html page means install/ update page?
Can you please share a reproduceable repo. I will be able to help quickly. Thanks

from vite-vue3-chrome-extension-v3.

14790897 avatar 14790897 commented on June 20, 2024
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';">

  <title>Word Cloud</title>
</head>
<body>
  <div id="app"></div>
  <script src="script.js"></script>
</body>
</html>

from vite-vue3-chrome-extension-v3.

14790897 avatar 14790897 commented on June 20, 2024

It can't find script.js in the same directory.

from vite-vue3-chrome-extension-v3.

14790897 avatar 14790897 commented on June 20, 2024
 const url = chrome.runtime.getURL('src/components/wordcloud.html');
  console.log('URL:', url); 
  chrome.tabs.create({ url: url }, (tab) => {
    if (chrome.runtime.lastError) {
      console.error(chrome.runtime.lastError);  
    } else {
      console.log('Tab created:', tab);  
    }
  });

from vite-vue3-chrome-extension-v3.

mubaidr avatar mubaidr commented on June 20, 2024

You should try using relative path for script, i.e. ./script.js

from vite-vue3-chrome-extension-v3.

14790897 avatar 14790897 commented on June 20, 2024

I was wrong before, the error is not about not finding the file but about the following error
image

from vite-vue3-chrome-extension-v3.

mubaidr avatar mubaidr commented on June 20, 2024

You are trying to use import statements inside static html page and scripts, which are not supported. Either add bundler (vite) processing for install and upgrade page or use simple scripts.

from vite-vue3-chrome-extension-v3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.