svg-inline-loader icon indicating copy to clipboard operation
svg-inline-loader copied to clipboard

Better parser

Open sairion opened this issue 8 years ago • 4 comments

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 avatar Sep 02 '15 03:09 sairion

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

sairion avatar Mar 09 '16 05:03 sairion

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).

ianwalter avatar Mar 17 '16 16:03 ianwalter

@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.

sairion avatar Mar 19 '16 14:03 sairion

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

ianwalter avatar Mar 19 '16 15:03 ianwalter