mixtur / webpack-spritesmith

Webpack plugin that converts set of images into a spritesheet and SASS/LESS/Stylus mixins
498 stars 56 forks source link

Multiple plugin for generating multiple sprites from different source images causes problems #92

Closed facinick closed 4 years ago

facinick commented 4 years ago

If i use two plugin: new SpritesmithPlugin({}) new SpritesmithPlugin({})

the lower one overrides few options of upper one like Handle bar template location.

--------------------------actual code where this happened----------------------------------------

new SpritesmithPlugin({
            src: {
                cwd: imagesPath,
                glob: "**/*.{jpg,png}",
            },
            target: {
                image: path.resolve(__dirname, "..", "dist/images/") + "/sprite.png",
                // this file will be used to import and access sprites.png
                css: [
                    [
                        path.resolve(__dirname, "..", "src/app/styles/") + "/sprites.less",
                        { format: "handlebars_based_template" },
                    ],
                ],
            },
            apiOptions: {
                cssImageRef: "sprite.png",
            },
            customTemplates: {
                handlebars_based_template:
                    path.resolve(__dirname, "..", "src/app/images/") + "/handlebarsStr.css.handlebars",
            },
        }),

        new SpritesmithPlugin({
            src: {
                cwd: path.resolve(__dirname, "..", "src/app/thirdparty/bjnui/src/sprites"),
                glob: "**/*.{jpg,png}",
            },
            target: {
                image: path.resolve(__dirname, "..", "src/app/thirdparty/bjnui/src/images") + "/sprite.png",
                css: [
                    [
                        path.resolve(__dirname, "..", "src/app/thirdparty/bjnui/src/styles") + "/sprites.less",
                        {
                            format: "handlebars_based_template",
                        },
                    ],
                ],
            }, 
            apiOptions: {
                cssImageRef: "sprite.png",
            },
            customTemplates: {
                handlebars_based_template:
                    path.resolve(__dirname, "..", "src/app/thirdparty/bjnui/src/sprites") +
                    "/handlebarsStr.css.handlebars",
            },
        }),
facinick commented 4 years ago

How can I use this plugin to generate different sprites from different sources?

mixtur commented 4 years ago

Use different format names.

facinick commented 4 years ago

Thanks!