3

I have a template npm package that has a bunch of assets in it. In an extension of the template, I am attempting to reference an asset from the template, which is installed as an npm dependency.

<div>
    <img src='template/assets/img/icons/back-arrow.svg' />
</div>

However, when i try to build it out using webpack, i get the error: Module not found: Error: Can't resolve './template/assets/img/icons/back- arrow.svg' in '/Users/Documents/GitProjects/MyProject/node_modules/test/html':

My webpack config is:

test: /\.(gif|jpg|jpeg|png|svg)$/,
            use: {
                loader: "file-loader",
                options: {
                    name: "./images/[path][name].[hash].[ext]",
                }
            }

Which seems to be working for all of my images in the MyProject folder, but I dont seem to be able to reference the assets in the template node_module. Is there a way to reference assets in a node_module without doing ../../node_modules/template/assets?

jekelija
  • 257
  • 4
  • 16

0 Answers0