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

When manifest provided, won't reload all scripts #111

Open
2 of 6 tasks
vjpr opened this issue Jun 19, 2020 · 0 comments
Open
2 of 6 tasks

When manifest provided, won't reload all scripts #111

vjpr opened this issue Jun 19, 2020 · 0 comments

Comments

@vjpr
Copy link

vjpr commented Jun 19, 2020

Type:

  • bug
  • feature
  • enhancement
  • question

Environment:

  • OS: macOS
  • Browser: Chrome
  • Library Version: v1.1.4

I'm going to open a PR:

  • yes
  • no

Description:

If manifest.json is provided, if something in entries.contentScript is not in the manifest.json#content_scripts.js is is silently removed.

const contentEntries: unknown = content_scripts
? flatMapDeep(Object.keys(webpackEntry), entryName =>
content_scripts.map(({ js }) =>
js
.map(contentItem => contentItem.replace(toRemove, ""))
.filter(contentItem => contentItem === entryName),
),
)
: null;

I have a situation similar to here where I need to access the window object. This requires injecting a separate entry point like so:

export default function injectScript(filePath, tag) {
  var node = document.getElementsByTagName(tag)[0]
  var script = document.createElement('script')
  script.setAttribute('type', 'text/javascript')
  script.setAttribute('src', filePath)
  node.appendChild(script)
}

injectScript(chrome.extension.getURL('content-script.js'), 'body')
  "content_scripts": [
    {
      "matches": ["foo.com"],
      "css": ["style.global.css", "style.css"],
      "js": ["content-script-injector.js"],
      "all_frames": false
    }
  ],

This functionality prevents reloads when content-script.js is changed.

Maybe adding another option to IEntriesOption to specify a file that will be always injected with the middleware.

@vjpr vjpr changed the title When manifest provided, won't reload all content scripts When manifest provided, won't reload all scripts Jun 19, 2020
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

1 participant