webpack-svg-sprite-sample icon indicating copy to clipboard operation
webpack-svg-sprite-sample copied to clipboard

a webpack SVG sprite sample when using Vue and React

trafficstars

Webpack SVG sprite sample project

###Usage

in Vue

npm run dev:vue
npm run build:vue

in React

npm run dev:react
npm run build:react

Update at 2016-06-05

Tricks:

  • Using svg-sprite-loader to build a svg sprite inject into body
  • Using svgo-loader to pretty svg files (you can see the icon panda, necessary attributes was removed)
  • Using the code below (require.context) to require all svg icons in one folder with webpack
const _require = require.context('../../assets/icons', false, /\.svg$/)
_require.keys().forEach(key => _require(key))