
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
vite-plugin-serve-static
Advanced tools
A Vite plugin for serving static files during local development
A simple Vite plugin for serving arbitrary static files that aren't in your public
directory.
// vite.config.ts
import path from "path";
import { defineConfig } from "vite";
import serveStatic from "vite-plugin-serve-static";
const serveStaticPlugin = serveStatic([
{
pattern: /^\/metadata\.json/,
resolve: "./metadata.json",
},
{
pattern: /^\/dog-photos\/.*/,
resolve: ([match]) => path.join("..", "dog-photos", match),
},
{
pattern: /^\/author-photos\/(.*)/,
resolve: (groups) => path.join("..", "authors", groups[1]) + ".jpg",
},
]);
export default defineConfig({
plugins: [serveStaticPlugin],
});
The configuration is defined as an array of objects defining which patterns to intercept and how to resolve them.
Each pattern
is defined as a regular expression. The resolve
property can either be a string containing the path to a single file or a function that returns a string given the result of executing the pattern
against the request path.
Licensed under the MIT License.
FAQs
A Vite plugin for serving static files during local development
The npm package vite-plugin-serve-static receives a total of 2,534 weekly downloads. As such, vite-plugin-serve-static popularity was classified as popular.
We found that vite-plugin-serve-static demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.