embroider-build / ember-auto-import

Zero config import from npm packages
Other
360 stars 109 forks source link

Add ability to pass options to `MiniCssExtractPlugin` #514

Closed boris-petrov closed 2 years ago

boris-petrov commented 2 years ago

In ember-cli-build.js in autoImport I have:

styleLoaderOptions: {
  attributes: {
    nonce: 'style-loader',
  },
  insert: function (element) {
    document.getElementsByTagName('head')[0].prepend(element);
  },
},

Which works great on ember-auto-import 2.4.1 in development but in production this is not executed and hence all styles are inserted as links at the end of head (which is the default behavior of style-loader - i.e. the insert option is not used at all). The same happens in 2.4.0 (it also had another issue). In 2.3.0 that is not the case and there all works fine.

cc @ef4

ef4 commented 2 years ago

style-loader is not recommended for production, so our default setup follows the recommendation of using it in development and using MiniCssExtractPlugin in production. Maybe what you really need is more control over the MiniCssExtractPlugin options?

boris-petrov commented 2 years ago

@ef4 thanks for taking a look into this. I didn't know that style-loader is not supposed to be used in production. Not sure what the difference is with MiniCssExtractPlugin but oh well. So yes, I do need what you suggest - more control over the MiniCssExtractPlugin options.

boris-petrov commented 2 years ago

hm, actually, you can pass options right now via miniCssExtractPluginOptions. So all is fine. Thank you for the support!

ef4 commented 2 years ago

If you can suggest a place where we could have documented this better for your use case, that would be helpful.

On Fri, Apr 22, 2022 at 5:32 AM Boris Petrov @.***> wrote:

Closed #514 https://github.com/ef4/ember-auto-import/issues/514.

— Reply to this email directly, view it on GitHub https://github.com/ef4/ember-auto-import/issues/514#event-6477157886, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACN6MVWARZ4IIOD75BOUMDVGJWZTANCNFSM5SPGWVFA . You are receiving this because you were mentioned.Message ID: @.***>

boris-petrov commented 2 years ago

Well, in this case this was my mistake - I hadn't read that style-loader shouldn't be used in production. But perhaps all these options could be documented in the README, that's true.