@gurso/vite-plugin-replace
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

vite-plugin-replace

What it does

Replace a file by a other file.

Example

with the default generated vite projet:

import { defineConfig } from "vite"
import fileReplace from "./index"

export default defineConfig({
    base: "./",
    plugins: [
        fileReplace({
            match: path => path === "/src/counter.ts",
        }),
    ],
}

the match function in config is required to declare files you want to replace.

By default the plugins look for a file start with the same name with the ext mock.ts instead to replace each file.

You can define how you want to define the filename for replacement with to replace function in config.

import { defineConfig } from "vite"
import fileReplace from "./index"

export default defineConfig({
    base: "./",
    plugins: [
        fileReplace({
            match: path => path.startWith("/src/services/")
            replace: path => path.replace("/src/services/", "/mock/")
        }),
    ],
}

/@gurso/vite-plugin-replace/

    Package Sidebar

    Install

    npm i @gurso/vite-plugin-replace

    Weekly Downloads

    1

    Version

    0.0.11

    License

    none

    Unpacked Size

    2.87 kB

    Total Files

    4

    Last publish

    Collaborators

    • gurso