nuxt-community / svg-module

Super simple svg loading module for Nuxt.js
MIT License
340 stars 35 forks source link

feat: Options to configure file-loader name property #75

Closed TroAlexis closed 2 years ago

TroAlexis commented 3 years ago

It was impossible to configure file-loader with module options. Furthermore, the default configuration was not the one of nuxtjs's.

Added default configuration for file-loader which matches nuxtjs's destination for images and made possible to pass options to the module. Added generate and start scripts to package.json to test out webpack context.

Module options may either be a function taking context as the argument in case you want to configure different names for files in development and production environment, or just an regular object.

manuelodelain commented 2 years ago

Hi @TroAlexis !

Thanks for the PR. I would be glad to merge it, could you fix the conflicts please?

About the default config, I'm not sure but maybe we should add [path] to the dev path as Nuxt does? https://github.com/nuxt/nuxt.js/blob/3ab12f9f104903b2c80813204b114f4103f1cc9b/packages/config/src/config/build.js#L20

TroAlexis commented 2 years ago

Thanks for your time @manuelodelain !

Conflicts resolved and you are absolutely right about Nuxt default file-loader name in dev, got that in 04c6c21 Updated the README.md as well to reflect the changes made to configuration.

I also couldn't get to work 'nuxt dev example' to work as the module.js now exports the svgModule function as the default with es6 modules, so I changed nuxt.config.js to import it accordingly if that's all right.