Skip to content

Replace files during Vite build - handy when replacing strings is not enough

License

Notifications You must be signed in to change notification settings

elwin013/vite-plugin-replace-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-plugin-replace-files

Replace files during Vite build - handy when replacing strings is not enough.

Install

Install with your favorite package manager (e.g. npm):

npm install -D vite-plugin-replace-files

Usage

This plugin should go before any other stuff in plugins array, so all other plugins that runs later could e.g. apply optimisations.

Add to vite.config.ts - example below will replace file src/env.ts with file conf/env.ts:

import { defineConfig } from 'vite';
import path from 'path';
import replaceFiles from 'vite-plugin-replace-files';

export default defineConfig({
  plugins: [
    replaceFiles([
      {
        file: path.join('src', 'env.ts'),
        replacement: path.join('conf', 'env.ts'),
      },
    ])
  ],
});

License

MIT

About

Replace files during Vite build - handy when replacing strings is not enough

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published