Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
compiler.plugin('emit', function (compilation, callback) {
let content = null;
const files = glob.sync('**/*.svg', {cwd: baseDir});
const svgSpriter = new SVGSprite({
mode: {
defs: true
},
shape: {
id: {
separator: '--'
}
}
});
files.forEach(function (file) {
svgSpriter.add(new vinyl({
path: path.join(baseDir, file),
base: baseDir,
contents: fs.readFileSync(path.join(baseDir, file))
}));
export default function run(opts, images) {
const config = _.defaultsDeep({}, opts.svgsprite);
const spriter = new SVGSpriter(config);
images.forEach(({ path }) => {
spriter.add(path, null, fs.readFileSync(path, { encoding: 'utf-8' }));
});
return Promise.promisify(spriter.compile, {
context: spriter,
multiArgs: true
})().spread((result, data) => {
const spritesheet = {};
spritesheet.extension = 'svg';
spritesheet.coordinates = {};
spritesheet.image = result.css.sprite.contents;
spritesheet.properties = {
width: data.css.spriteWidth,