B
B
Bowen2017-01-05 14:33:11
Pug
Bowen, 2017-01-05 14:33:11

How to solve the problem with copying images included in pug/jade?

Hello others.
There is a component:

/home
    /images
        logo.png
    home.component.ts
    home.template.pug
    home.styles.styl
    index.ts

Part of the webpack config:
{
        test: /\.(png|jpe?g|ico)$/,
        use: [{
          loader: 'file-loader',
          options: {
            context: './src/app/',
            name: '[path][name].[ext]'
          }
        }]
}

In the component template, I specify this:
img(src=require("./images/logo.png") class="logo")
After compilation, images are not copied to the dist folder.
I believe this is a pug-loader bug, but unfortunately I could not solve it.
Has anyone encountered such a problem? if so, how did you solve it?
Any advice/help would be greatly appreciated!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bowen, 2017-01-05
@Bowen

I solved the problem using the following loaders:

{
  test: /\.pug$/,
  use: [{
    loader: 'html-loader'
  }, {
    loader: 'pug-html-loader',
    options: {
      exports: false
    }
  }]
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question