dva roadhog 1.x uses the svg method after upgrading roadhog 2.x

1. Add the webapck.config.js file to the root directory

2. Add the following code

const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');

module.exports = (webpackConfig, env) => {

  webpackConfig.module.rules.forEach(item => {
    if (String(item.loader).indexOf('url-loader') > -1) {
      item.exclude.push(/\.svg$/)
    }
  })

  webpackConfig.module.rules = [
    ...webpackConfig.module.rules,
    ...[
      {
        test: /\.(svg)$/i,
        loader: 'svg-sprite-loader',
      },
    ],
  ]

  webpackConfig.plugins = webpackConfig.plugins.concat([
    new SpriteLoaderPlugin(({
      plainSprite: true,
      spriteAttrs: {
        id: '__SVG_SPRITE_NODE__'
      }
    })),
  ]);

  return webpackConfig;
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325001869&siteId=291194637