W
W
Wasya UK2018-08-30 19:23:19
webpack
Wasya UK, 2018-08-30 19:23:19

How to correctly substitute the path to images in webpack?

Why does webpack incorrectly substitute the path to images? (substituting all paths, didn't help)
src
--assets
--pug
----pages // calling here
Module not found: Error: Can't resolve './.../assets/iphone.png' in 'C :\project\src\pug\pages':
img(src=".../assets/iphone.png")

{
        test: /\.(pug|jade)$/,
        exclude: /(node_modules)/,
        use:  [
          'html-loader',
          {
            loader: 'pug-html-loader',
            options: {
              data: {}
            }
          }
        ]
      },
{
        test: /\.(jpe?g|png|gif|svg)$/i,
        use: [
          {
            loader: 'file-loader',
            options: {
              emitFile: true,
              name: 'images/[name]-[sha512:hash:base64:12].[ext]'
            }
          }
        ]
      }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Egorov, 2018-08-30
@dmc1989

'. /.../assets/iphone.png ' there are three dots (should be two). If it doesn't work, try removing the ./

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question