webpack-contrib / svg-inline-loader

Inline SVG loader with cleaning-up functionality
MIT License
491 stars 59 forks source link

Better parser #9

Open sairion opened 9 years ago

sairion commented 9 years ago

simple-html-tokenizer has some problem. First of all, it does not understand HTML and SVG namespace and elements correctly (which makes us to expand self-closing tag manually via regex)

Secondly, it just gives array of parsed tag sequence rather than structured object. This makes code quite verbose (which I did not realize at first use)

simple-html-tokenizer is pretty fast and lightweight but we need parser with better output.

sairion commented 8 years ago

https://github.com/tautologistics/node-htmlparser

ianwalter commented 8 years ago

How about using SVGO instead of the custom code? There are loaders for SVGO but I don't think I have been able to find any that inline the SVG for you and is platform-independent (i.e. you could use on React or Vue).

sairion commented 8 years ago

@ianwalter I believe you can use svgo-loader + raw-loader to have almost same, or better effect this loader gives. In fact svg inlining is pretty much nothing but pasting contents into a webpack module (which raw-loader does). For the matter of fact, this loader should work platform-independent either. I built this loader for lower install overhead because svgo-loader (or svgo) has a bit huge for small tasks.

ianwalter commented 8 years ago

@sairion Thanks, I came to the same conclusion (except using text-loader instead of raw-loader). Cheers!