Code Monkey home page Code Monkey logo

Comments (2)

lgordey avatar lgordey commented on June 29, 2024

Thanks for your feedback!
I look at it to make it clear on which side the problem: svgo lib or our plugin

from webpack-svgstore-plugin.

DavidWells avatar DavidWells commented on June 29, 2024

Man o man those SVGO docs sure could use some work =P

This was the answer: https://twitter.com/DavidWells/status/741005631734321152

I managed to figure out the solution and exactly how to configure this webpack plugin.

var path = require('path')
var fs = require('fs')
var webpack = require('webpack')
var packageInfo = require('./package')
var SvgStore = require('webpack-svgstore-plugin')

// define local variables
var distPath = path.join(__dirname, 'src', 'sprite')
var sourcePath = path.join(__dirname, 'src', 'assets')

var config = {
  entry: {
    index: path.join(__dirname, 'src', 'dummy-entry.js'),
  },
  output: {
    path: distPath,
    filename: '[name].js',
    chunkFilename: '[chunkhash].[id].js',
    publicPath: '/lib/'
  },
  resolve: {
      extensions: ['', '.js'],
  },
  plugins: [
    new SvgStore(path.join(sourcePath, '**/*.svg'), path.join('svg'), {
      svg: {
        xmlns: 'http://www.w3.org/2000/svg',
        style: 'position:absolute; width: 0; height: 0'
      },
      name: 'sprite.svg',
      chunk: 'index',
      prefix: '',
      svgoOptions: {
        plugins: [{
          cleanupAttrs: true,
        }, {
          removeDoctype: true,
        },{
          removeXMLProcInst: true,
        },{
          removeComments: true,
        },{
          removeMetadata: true,
        },{
          removeTitle: true,
        },{
          removeDesc: true,
        },{
          removeUselessDefs: true,
        },{
          removeEditorsNSData: true,
        },{
          removeEmptyAttrs: true,
        },{
          removeHiddenElems: true,
        },{
          removeEmptyText: true,
        },{
          removeEmptyContainers: true,
        },{
          removeViewBox: false,
        },{
          cleanUpEnableBackground: true,
        },{
          convertStyleToAttrs: true,
        },{
          convertColors: true,
        },{
          /* https://github.com/svg/svgo/blob/master/plugins/convertPathData.js#L9-L26 */
          //convertPathData: false,
          convertPathData: {
              applyTransforms: true,
              applyTransformsStroked: true,
              makeArcs: {
                  threshold: 2.5, // coefficient of rounding error
                  tolerance: 0.5  // percentage of radius
              },
              straightCurves: true,
              lineShorthands: true,
              curveSmoothShorthands: true,
              floatPrecision: 3.33,
              transformPrecision: 3,
              removeUseless: true,
              collapseRepeated: true,
              utilizeAbsolute: true,
              leadingZero: true,
              negativeExtraSpace: true
          },
        },{
          convertTransform: true,
        },{
          removeUnknownsAndDefaults: true,
        },{
          removeNonInheritableGroupAttrs: true,
        },{
          removeUselessStrokeAndFill: true,
        },{
          removeUnusedNS: true,
        },{
          cleanupIDs: true,
        },{
          cleanupNumericValues: true,
        },{
          moveElemsAttrsToGroup: true,
        },{
          moveGroupAttrsToElems: true,
        },{
          collapseGroups: true,
        },{
          removeRasterImages: false,
        },{
          mergePaths: true,
        },{
          convertShapeToPath: true,
        },{
          sortAttrs: true,
        },{
          transformsWithOnePath: false,
        },{
          removeDimensions: true,
        },
        //{
        //   removeAttrs: {attrs: '(stroke|fill)'},
        // }
        ]
      }
    })
  ],
  module: {
    loaders: [
      {
        test: /\.js/,
        loaders: ['babel']
      }
    ]
  }
}

module.exports = config

from webpack-svgstore-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.