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

CSS not imported when building for production #87

Open
chadhutchins opened this issue May 26, 2020 · 8 comments
Open

CSS not imported when building for production #87

chadhutchins opened this issue May 26, 2020 · 8 comments

Comments

@chadhutchins
Copy link

Hello, thank you for this great library!

We've been working in development for a while on our browser extension, and now we're ready to start using production builds.

Everything seems to be working perfectly except when we run a production build (yarn build) the CSS is not applied to our content script. I can see the css files are generated and placed within a /css folder, but it's like it is never referenced by the javascript.

One thing that may be a little different than the standard project is that we are adding a Vue app to the content script.

Is there something else we need to do?

@chadhutchins
Copy link
Author

@adambullmer any thoughts on this? happy to support you and this project if we can get some help on this. Thanks!

@JamesDommisse
Copy link

I ran into the same issue, and was able to solve it by:

// vue.config.js
module.exports = {
    filenameHashing: false
    ...
}
  • And then adding the generated css to the manifest:
// src/manifest.json
{
  ...
  "content_scripts": [
    {
      "matches": ["*://*/*"],
      "js": ["js/content-script.js"],
      "css": ["css/content-script.css"]
    }
  ],
...
}

Hope that helps.

@chadhutchins
Copy link
Author

Thanks @JamesDommisse will give this a look!

@mmohaveri
Copy link

@JamesDommisse I did as you said, now my development is broken as during development webpack does not create the css files, is there a way to tell webpack to edit the manifest on production?

@mmohaveri
Copy link

For other people that might end up here, you can add a manifestTransformer function to the plugins options and in that remove the css from contnet_scripts if it's running in development.

@michaelbukachi
Copy link

@mmohaveri Do you mind providing a snippet?

@stffndtz
Copy link

stffndtz commented Mar 11, 2021

@michaelbukachi you should be able to do this (targeting the second entry of the content_scripts):

manifestTransformer: (manifest) => {
  if (process.env.NODE_ENV === "development") {
    manifest.content_scripts[1].css.pop();
  }
  return manifest;
},

@michaelbukachi
Copy link

@michaelbukachi you should be able to do this (targeting the second entry of the content_scripts):

manifestTransformer: (manifest) => {
  if (process.env.NODE_ENV === "development") {
    manifest.content_scripts[1].css.pop();
  }
  return manifest;
},

Thanks.

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

5 participants