GithubHelp home page GithubHelp logo

bydiogosampaio / esbuild-plugin-svg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nativew/esbuild-plugin-svg

0.0 0.0 0.0 5 KB

Svg files import plugin for esbuild.

License: ISC License

JavaScript 100.00%

esbuild-plugin-svg's Introduction

esbuild-plugin-svg

Svg files import plugin for esbuild.


Install

npm install esbuild-plugin-svg -D

String

import iconLogo from './logo.svg';

render() {
    return `
        ${iconLogo}
    `;
}

Custom element

import './logo.svg';

render() {
    return `
        <icon-logo></icon-logo>
    `;
} // namespace + filename

Use

esbuild.config.json

import esbuild from 'esbuild';
import svg from 'esbuild-plugin-svg';

esbuild
    .build({
        entryPoints: ['index.js'],
        bundle: true,
        outfile: 'main.js',
        plugins: [svg()]
    })
    .catch(() => process.exit(1));

package.json

{
    "type": "module",
    "scripts": {
        "start": "node esbuild.config.js"
    }
}

Configure

esbuild.config.json

svg({
    customElement: false,
    namespace: 'icon', // namespace custom elements
    minify: false, // with svgo
    minifyOptions: {} // svgo options
});

Includes

SVGO   →   Optimizes svg files.


Check

esbuild-serve   →   Serve with live reload for esbuild.

esbuild-plugin-pipe   →   Pipe esbuild plugins output.

esbuild-plugin-babel   →   Babel plugin for esbuild.

esbuild-plugin-postcss-literal   →   PostCSS tagged template literals plugin for esbuild.


esbuild-plugin-svg's People

Contributors

hum-n avatar

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.