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-vendor

v1.3.3

Published

Generates vendor bundles based on the specified options

Downloads

5

Readme

Vite Plugin Vendor

The Vite Plugin Vendor is a ViteJS plugin that generates vendor bundles based on the specified options. This plugin allows you to include specific vendor dependencies in your build and customize their output.

How It Works

The plugin scans the dependencies section of the package.json file to fetch vendor entries. Each entry corresponds to a vendor package, and the plugin will look for files that match the specified globs in the dist directory of the vendor package.

During the build process, the plugin will copy the identified files to the specified destination directory.

Install

You can install the Vite Plugin Vendor using npm or yarn:

# With npm
npm i -D vite-plugin-vendor

# With yarn
yarn add vite-plugin-vendor --dev

Usage

To use the plugin, simply import it and add it to the plugins array in your Vite config file:

// vite.config.js
import pluginVendor from 'vite-plugin-vendor'

export default {
  plugins: [
    pluginVendor({
      applyOnMode: true,
      dest: 'vendor',
      manualEntry: {
        'my-vendor': {
          files: 'dist/my-vendor.js',
          flat: true
        }
      }
    })
  ]
}

Options

The Vite Plugin Vendor accepts the following options:

applyOnMode (optional)

Determines which build modes this plugin should apply to.

  • If true, the plugin will apply to all build modes.
  • If false, the plugin will apply to no build modes.
  • If an array of strings is provided, the plugin will only apply to the specified build modes.

Default value: true

dest (optional)

The destination directory for generated vendor files. The generated vendor files will be placed in this directory.

Default value: 'vendors'

manualEntry (optional)

You can manually specify vendor entries and their details using the manualEntry option. This is useful when you want to include specific files that are not covered by the automatic scanning of the package.json dependencies.

Example:

// vite.config.js
import pluginVendor from 'vite-plugin-vendor'

export default {
  plugins: [
    pluginVendor({
      manualEntry: {
        bootstrap: {
          files: ['dist/js/bootstrap.js', 'dist/js/bootstrap.min.js'],
          flat: true,
          rename: filepath => {
            const version =
              require('./node_modules/bootstrap/package.json').version
            return filepath.replace(/\.js$/, `-${version}.js`)
          }
        }
      }
    })
  ]
}
  • files: The file or files to include in the vendor bundle. It can be a string or an array of strings representing file paths or globs.
  • flat (optional): Whether to flatten the file structure of the vendor bundle. If true, all files will be placed in the root of the vendor bundle. If false, the file structure of the source files will be preserved. Default value: false.
  • rename (optional): A new name or rename function for each file in the vendor bundle. It can be a string to rename all files to the same name, or a function that takes a file path and returns a new name.

License

GitHub

A project by Stilearning © 2023.