mrsum / webpack-svgstore-plugin

Simple svg-sprite creating with webpack
https://www.npmjs.com/package/webpack-svgstore-plugin
200 stars 92 forks source link

3.x breaking change? #102

Closed ZebraFlesh closed 7 years ago

ZebraFlesh commented 8 years ago

I tried to upgrade from 2.x to 3.x and my webpack process no longer outputs SVG sprites. It seems like an additional assumption was added in version 3. What's the minimum that needs to occur for this plugin to produce a sprite?

Here's my very simple webpack.config.js. I'm producing a library and leaving all of the transpilation and bundling up to consumers.

const CopyWebpackPlugin = require('copy-webpack-plugin');
const SvgStore = require('webpack-svgstore-plugin');

const PATHS = {
    src: './src',
    lib: './lib'
};

const sprite = new SvgStore('./assets/svg/*.svg', './lib/svg', {
    name: 'dlssprite.svg',
    prefix: '',
    svgoOptions: {
        // options for svgo
        plugins: [
            { removeTitle: true },
            { addClassesToSVGElement: 'injected-svg' },
            { removeStyleElement: true }
        ]
    }
});

const copyToOutputDir = new CopyWebpackPlugin([{
    from: PATHS.src,
    to: PATHS.lib
}]);

module.exports = {
    output: {
        path: __dirname,
        filename: '[name].js'
    },
    module: {
        loaders: [
            {
                test: /.*/,
                loader: 'file-loader'
            }
        ]
    },
    plugins: [
        copyToOutputDir,
        sprite
    ]
};
mrsum commented 8 years ago

Hi @ZebraFlesh look here https://github.com/mrsum/webpack-svgstore-plugin/blob/develop/README.md

3.x version is almost refactored and using new logic

ZebraFlesh commented 8 years ago

I read that, but it didn't really shed any light on why something that to used to work now does not. It looks like the options I'm passing to webpack-svgstore-plugin are correct, but it's simply not running -- like its running was moved to a different phase of compilation or something.

eilinora commented 8 years ago

I'm also encountering this same issue. Before it automatically injected the generated output into the page, this appears not to be happening anymore, or even processing the svg sprites when tracing through the component logic

Bercon commented 7 years ago

Yeah it'd be nice to have migration documentation from 2.x.x to 3.x.x. Seems like this requires significant changes to how the webpack-svgstorage-plugin is used

mrsum commented 7 years ago

@eilinora @Bercon actually its small changes. If you still have question, have a look at this url https://github.com/mrsum/webpack-svgstore-plugin/tree/develop/platform

this folder contain actual settings for webpack

ZebraFlesh commented 7 years ago

Respectfully, these are large changes. Previously it was possible to include this plugin and have it process a directory of SVGs into a sprite sheet. There was no requirement to require the SVG files in your javascript with 2.x and earlier -- it just worked. But now with 3.x, that mode of execution is no longer possible.

I think all of the people who are showing up here and asking very confused questions were previously using this plugin in the manner I described. And we're very surprised that moving up to version 3.x completely breaks this mode of operation.