vite-plugin-npm-static-files
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

vite-plugin-npm-static-files

Vite plugin to serve raw files from NPM as static assets. For example, if you have a legacy app that requires unbundled jQuery in addition to bundled components, and you would like to use vite, you may still want to be able to load jQuery from its NPM package instead of copying it into your project or loading it from a CDN.

Limitations

At present, this plugin will not rewrite references to such files in index.html, which means it is only useful if integrated with a backend (e.g. ASP.net, rails, etc), as described in Backend Integration

Usage

In your vite.config.ts, add the plugin with an object mapping file names to package paths. Files will be served at /npm/<name>

import { defineConfig } from "vite";
import npmStaticFilesPlugin from "vite-plugin-npm-static-files";

export default defineConfig({
	plugins: [
		npmStaticFilesPlugin({
      'jquery.js': 'jquery/dist/jquery.min.js',
    })
	],
});

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-npm-static-files

Weekly Downloads

89

Version

0.1.1

License

MIT

Unpacked Size

4.78 kB

Total Files

5

Last publish

Collaborators

  • maths22