Coder Social home page Coder Social logo

pmcalmeida / preact-cli-svg-loader Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 3.0 94 KB

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

JavaScript 100.00%

preact-cli-svg-loader's Introduction

Hi there 👋

preact-cli-svg-loader's People

Contributors

dependabot[bot] avatar palmeidaminder avatar pmcalmeida avatar vorobey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

preact-cli-svg-loader's Issues

Usage example

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!

bug with preactCliSvgLoader

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 :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.