vite-plugin-cache-resource
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

vite-plugin-cache-resource

cache request contents to local files

usage

install

pnpm add vite-plugin-cache-resource -D

config

add cacheResource to vite config

import { cacheResource } from "vite-plugin-cache-resource";

export default defineConfig({
  plugins: [
    cacheResource(),
  ],
});

options

  • cacheDir: where the files are saved to
    • default: ${process.cwd()}/tmp
import path from "path/posix";
import { defineConfig } from "vite";
import { cacheResource } from "vite-plugin-cache-resource";

export default defineConfig({
  plugins: [
    cacheResource({
      cacheDir: path.join(__dirname, ".cache"),
    }),
  ],
});

text content

import example from "cache:https://example.com";

expect(
  parse(example).querySelector("title").textContent
).toMatchInlineSnapshot('"Example Domain"');

json

import todo from "cache+json:https://jsonplaceholder.typicode.com/todos/1";

expect(todo["title"]).toMatchInlineSnapshot('"delectus aut autem"');

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-cache-resource

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

10.3 kB

Total Files

7

Last publish

Collaborators

  • __yue__