Kocal / vue-web-extension

🛠️ A Vue CLI 3+ preset (previously a Vue CLI 2 boilerplate) for quickly starting a web extension with Vue, Babel, ESLint and more!
https://vue-web-extension.netlify.app/
MIT License
1.58k stars 167 forks source link

executeScript with a file? #662

Open pasikonik opened 3 years ago

pasikonik commented 3 years ago

I'm wondering, how can I set script file for executeScipt?

  browser.tabs.executeScript(null, {
    file: 'script.js'
  }, (result) => {
    ...
  });

Is it require different build with separated file or is it possible to do it in a simpler way?

My current workaround looks like this:

  import { bodyOfMethod } from '@/js/script'

  browser.tabs.executeScript(null, {
    code: `(${bodyOfMethod})()`
  }, (result) => {
    ...
  });

but it looks hacky to me.