Webpack dynamically create a module

后端 未结 2 1609
长发绾君心
长发绾君心 2021-02-04 06:53

I am writing a plugin which creates a SVG sprite. It globs over the directories, merge SVG files in one image and returns the result. The idea is to dynamically create a module

2条回答
  •  醉话见心
    2021-02-04 07:50

    Try taking a look at how external and delegated modules are provided in Webpack. A good place to start is the ExternalModuleFactoryPlugin or DllReferencePlugin.

    Essentially, you create a plugin for the NormalModuleFactory which takes requests for modules, you match those which should resolve to the modules you are generating and you can asynchronously respond with a Module.

提交回复
热议问题