0.1.8 • Published 1 year ago

@twoday/vite-plugin-super-template v0.1.8

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@twoday/vite-plugin-super-template

Vite plugin for super-template.

Usage

vite.config.js:

import superTemplate from '@twoday/vite-plugin-super-template';
import { defineConfig } from 'vite';

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

Options

Default options can be tweaked or replaced entirely.

Replace @twoday/babel-preset-formatjs with babel-plugin-formatjs

import superTemplate, {
  defaultOptions,
} from '@twoday/vite-plugin-super-template';
import { defineConfig } from 'vite';

const withOriginalFormatJSBabelPlugin = (options) => {
  const { plugins, presets } = options.react.babel;

  const indexOftwodayFormatJSPreset = presets.findIndex(
    (preset) => preset === '@twoday/formatjs'
  );

  presets.splice(indexOftwodayFormatJSPreset, 1);
  plugins.push('formatjs');

  return options;
};

export default defineConfig({
  plugins: [superTemplate(withOriginalFormatJSBabelPlugin(defaultOptions))],
});