cascornelissen / svg-spritemap-webpack-plugin

SVG spritemap plugin for webpack
MIT License
207 stars 50 forks source link

Do not working wds without svg #135

Closed wakenby closed 3 years ago

wakenby commented 3 years ago

If you run wds with an empty icon folder and then add icons, then the svg-spritemap-webpack-plugin will not work.

But if you run wds with any icon, then adding new svg-spritemap-webpack-plugin will work fine.

config:

const SvgSpriteMapWebpackPlugin = require('svg-spritemap-webpack-plugin')
const cwd = require('../cwd')

module.exports = [
  new SvgSpriteMapWebpackPlugin(cwd('src/static/icons/*.svg'),
    {
      output: {
        filename: 'assets/sprite/sprite.svg',
        svgo: true
      },
      sprite: {
        prefix: false,
        generate: {
          title: false
        }
      }
    }
  )
]
const { merge } = require('webpack-merge')
const dev = require('./webpack.dev')
const cwd = require('./slices/cwd')

module.exports = merge(dev, {
  devServer: {
    injectClient: true,
    contentBase: cwd('dist'),
    watchContentBase: true,
    port: 8080,
    open: true,
    overlay: {
      warnings: true,
      errors: true
    }
  }
})
cascornelissen commented 3 years ago

That was quite the edge case but I'm pretty sure the fix in b5c1071 solves this really well. Can you try out the changes and report back?

You can install these recent changes directly from GitHub using the following command.

npm install cascornelissen/svg-spritemap-webpack-plugin#master

Let me know if it solves the issue on your side ✌🏼

wakenby commented 3 years ago

Works!!!

But if there are no icons, then an empty sprite.svg is still created((

cascornelissen commented 3 years ago

@wakenby, good point, didn't notice that. The changes in c009e6e should fix this. Could you test it out once more by installing it directly from master?

wakenby commented 3 years ago

Perfect work!!!

cascornelissen commented 3 years ago

These changes were included in 3.8.0, thanks once more for reporting the issue! 🚀