0.1.13 • Published 4 months ago

vite-plugin-filter-replace v0.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

vite-plugin-filter-replace npm

Apply filename based replacements.

import vue from '@vitejs/plugin-vue';
import replace from 'vite-plugin-filter-replace';

export default {
  plugins: [
    replace([
      {
        filter: /\.css$/,
        replace: {
          from: /__foo__/g,
          to: 'foo',
        },
      },
      {
        filter: /\.css$/,
        replace: [
          { from: /__foo__/g, to: 'foo' },
          { from: /__(foo)__/g, to: '$1' },
        ],
      },
      {
        filter: ['node_modules/moment/dist/moment.js'],
        replace(source, path) {
          return 'some code';
        },
      },
    ]),
  ],
};

Options

interface Replacement {
  filter: RegExp | string | string[];
  replace: Array<{
    from: RegExp | string | string[]; to: string | number; } |
    (source: string, path: string) => string
  > | ((source: string, path: string) => string)
    | { from: RegExp | string | string[]; to: string | number; };
}

interface Options {
  enforce?: 'pre' | 'post';
  apply?: 'serve' | 'build';
}

License

MIT

0.1.13

4 months ago

0.1.12

11 months ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago