M
M
mrSeller2018-04-24 19:50:19
webpack
mrSeller, 2018-04-24 19:50:19

How to disable image checking in styles in webpack?

In the assembly, all the statics are in a separate folder, there are also pictures, as a result, these pictures are moved to the root when assembling the entire folder:

- public
    - index.html
    - app.js
    - images
    - fonts
- src
    - index.pug
    - app.js
    - static
        - images
        - fonts
        - ...

Styles are compiled into a JS file and from there, when the page (banner) is opened, they are sent straight to <head />.
For the banner, you need to specify relative paths, i.e. for background images, I prescribe './images/', but one of the css-loaders (style-loader, css-loader, stylus-loader) for some hell checks the presence of an image in this path BEFORE building, and of course there these pictures are not there, because app.js is in src, and the pictures folder is one level lower, so an error is thrown and nothing is going to happen.
Is it possible to disable this check?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2018-04-24
@ilyapashkov02

You can specify in the config where to put pictures after processing by webpack, in the name key (publicPath variable depending on the environment in my config)

{
    test: /\.(png|jpg|jpeg|gif)$/,
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 8192,
              name: 'assets/images/[name].[ext]',
              publicPath
            }
          }
        ]
      },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question