D
D
DanakayShorohov9862020-07-11 15:13:18
webpack
DanakayShorohov986, 2020-07-11 15:13:18

How to add a rule to an existing one in vue.config.js?

Good afternoon. How to add a new rule with resourceQuery to an already existing base loader in vue webpack config?

The simplest example of what this is for is an svg loader with a parameter. For example require('icon.svg') should return the path, and require('icon.svg?inline') should return the svg code.

Tried like this but it didn't work for some reason

vue.config.js code

module.exports = {
  chainWebpack: config => {
    const svgRule = config.module.rule("svg");

    svgRule
      .resourceQuery(/inline/)
      .use("svg-inline-loader")
      .loader("svg-inline-loader");
  }
};

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