ferdinandtorggler / extract-svg-styles Goto Github PK
View Code? Open in Web Editor NEWExtract SVG element's <style> tags to files.
Extract SVG element's <style> tags to files.
Tools like Inkscape generate inline styles as attributes on nodes.
I wanted to use extract-svg-styles to generate two files: svg with the shape of an icon, and css with colours etc. The goal was to be able to dynamically change color of icon on state change (for example :hover could be red, disabled grey etc.).
However currently styles from attributes are not extracted.
Attached is an example of icon I have troubles with.
similar_question.zip
The part:
var extractSvg = require(‘extract-svg-styles’);
extractSvg.extract(options);
fails.
ReferenceError: primordials is not defined
index.js
var extractSvg = require('extract-svg-styles');
extractSvg.extract({
src: './test/*.svg',
out: {
style: './test/dest/css',
svg: './test/dest/svg'
},
classPrefix: 's-'
});
➜ POC git:(feature/initial-testing) ✗ node index.js
fs.js:47
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:47:5
at req_ (/Users/sylwestermielniczuk/Documents/works/diorama-sylwester/demos/html-svg/pocs/0111/POC/node_modules/natives/index.js:143:24)
at Object.req [as require] (/Users/sylwestermielniczuk/Documents/works/diorama-sylwester/demos/html-svg/pocs/0111/POC/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/Users/sylwestermielniczuk/Documents/works/diorama-sylwester/demos/html-svg/pocs/0111/POC/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
➜ POC git:(feature/initial-testing) ✗
When I run node ./test/test.js I get
C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\css\lib\parse\index.js:72
throw err;
^
Error: undefined:7:1: missing '{'
at error (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\css\lib\parse\index.js:62:15)
at declarations (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\css\lib\parse\index.js:247:25)
at rule (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\css\lib\parse\index.js:560:21)
at rules (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\css\lib\parse\index.js:117:70)
at stylesheet (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\css\lib\parse\index.js:81:21)
at Object.module.exports [as parse] (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\css\lib\parse\index.js:564:20)
at nestCSS (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\index.js:67:22)
at DestroyableTransform.extractStyles [as _transform] (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\index.js:156:21)
at DestroyableTransform.Transform._read (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.
js:184:10)
at DestroyableTransform.Transform._write (C:\Users\qbolec\Documents\GitHub\extract-svg-styles\extract-svg-styles\node_modules\through2\node_modules\readable-stream\lib\_stream_transform
.js:172:12)
npm ERR! Test failed. See above for more details.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.