adambullmer / vue-cli-plugin-browser-extension

Browser extension development plugin for vue-cli 3.0
GNU Lesser General Public License v3.0
427 stars 76 forks source link

CSS not imported when building for production #87

Open chadhutchins opened 4 years ago

chadhutchins commented 4 years ago

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 commented 4 years ago

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

JamesDommisse commented 4 years ago

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

// vue.config.js
module.exports = {
    filenameHashing: false
    ...
}

Hope that helps.

chadhutchins commented 4 years ago

Thanks @JamesDommisse will give this a look!

mmohaveri commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@mmohaveri Do you mind providing a snippet?

stffndtz commented 3 years ago

@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 commented 3 years ago

@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.