npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-singlefile-escaped

v1.1.7

Published

<div align="center"> <img src="https://github.com/runmaxde/vite-plugin-singlefile-escaped/assets/41482988/9a8a6682-621d-42c6-98e2-91e001fdfb14" height="128" /> <h1>SingleFile Escaped 📦🧣</h1> <h3><a href="https://vitejs.dev/guide/using-plugins">Vit

Downloads

12

Readme

vite-plugin-singlefile-escaped

This Vite plugin allows you to escape the output of vite-plugin-singlefile and optionally wrap it with custom strings before and after. It uses jsesc to escape the content, making it safe for embedding in specific environments or as part of a larger string. Installation

npm install vite-plugin-singlefile-escaped --save-dev`

or if you prefer using Yarn:

yarn add vite-plugin-singlefile-escaped --dev

Usage

To use vite-plugin-singlefile-escaped in your Vite project, import it into your vite.config.js or vite.config.ts and add it to the plugins array. You also need to have vite-plugin-singlefile installed and configured, as this plugin works on its output.

// vite.config.js
import { viteSingleFile } from "vite-plugin-singlefile";
import viteSingleFileEscaped from "vite-plugin-singlefile-escaped";

export default {
  plugins: [
    viteSingleFile(),
    viteSingleFileEscaped()
  ],
};

Configuration

viteSingleFileEscaped accepts two optional parameters to customize the wrapping of the escaped content and an optional posibility of a configuration for more precise escaping

function viteSingleFileEscaped(wrapBefore: string, wrapAfter: string, config: object): void
  • wrapBefore: A string to prepend before the escaped content.
  • wrapAfter: A string to append after the escaped content.
  • config: A destructured object that allows to add special configurations Jsesc Docs

If not provided, these parameters default to an empty string, meaning no wrapping will be applied beyond escaping the content. Example

Here is an example configuration that escapes the entire output of your single-file bundle and wraps it in a JavaScript log function:

// vite.config.js
import { viteSingleFile } from "vite-plugin-singlefile";
import viteSingleFileEscaped from "vite-plugin-singlefile-escaped";

export default {
  plugins: [
    viteSingleFile(),
    viteSingleFileEscaped('console.log("', ");", { quotes: "double" }),
  ],
};
// dist/index.html
console.log("<ESCAPED_CODE_PLACEHOLDER>");

This setup escapes the single-file output and wraps it with console.log(" at the beginning and "); at the end, making it ready to be logged directly to the console as part of a larger script or debugging tool.

License

This plugin is open-sourced software licensed under the MIT license.