S
S
shasoft2019-07-14 15:42:36
JavaScript
shasoft, 2019-07-14 15:42:36

How to include images via require as images in webpack?

Configured in vue.config.js

{
          test: /\.(jpe?g|png|gif)$/,
          loader: 'url-loader',
          options: {
            // Images larger than 10 KB won’t be inlined
            limit: 256,
            name: "images/[name].[hash].[ext]",
          }
        },

In the code, I insert the image as At startup, I see that the image file has appeared in the resources. But at the same time, the image was inserted into the code in the format Why is the image not inserted as a link to the file? ps Or maybe because the picture is used only once and for optimization it was added to the js code?
require('./images/pen.png')
src="data:image/png;base64,

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question