pmcalmeida / preact-cli-svg-loader Goto Github PK
View Code? Open in Web Editor NEWRemoves svg extension file-loader, url-loader and raw-loader and use preact-svg-loader to load svg file as preact components in preact-cli
License: MIT License
Removes svg extension file-loader, url-loader and raw-loader and use preact-svg-loader to load svg file as preact components in preact-cli
License: MIT License
It'd be nice if the README had a code sample for how to import an SVG using this loader in a project created with Preact CLI.
In other blogs/articles, I'm seeing this sort of syntax:
import { ReactComponent as Tree } from '../images/tree.svg'
But it looks like instead this library allows for a default import, e.g.
import Tree from '../images/tree.svg'
Also, might be worth clarifying how to get it to work with Typescript. There's probably a better way, but this works:
// declaration.d.ts
declare module '*.svg' {
const content: FunctionComponent;
export default content;
}
Just figured this would help others coming from React. Thanks!
export default (config, helpers) => {
preactCliSvgLoader(config, helpers);
config.resolve.alias = {
...config.resolve.alias,
"~@": resolve(__dirname, "src"),
image: resolve(__dirname, "src/assets/img"),
};
config.node.process = true;
return config;
};
tried to install library as non-dev dep, tried to comment my changes, nothing helps :(
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.