0.1.7 • Published 6 months ago

@postinumero/unplugin-formatjs v0.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

@postinumero/unplugin-formatjs

Preconfigured. Minimal setup.

Install

npm i @postinumero/unplugin-formatjs --save-dev
// vite.config.ts
import formatjs from "@postinumero/unplugin-formatjs/vite";

export default defineConfig({
  plugins: [
    formatjs({
      /* options */
    }),
  ],
});

// rollup.config.js
import formatjs from "@postinumero/unplugin-formatjs/rollup";

export default {
  plugins: [
    formatjs({
      /* options */
    }),
  ],
};

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require("@postinumero/unplugin-formatjs/webpack")({
      /* options */
    }),
  ],
};

// nuxt.config.js
export default defineNuxtConfig({
  modules: [
    [
      "@postinumero/unplugin-formatjs/nuxt",
      {
        /* options */
      },
    ],
  ],
});

This module works for both Nuxt 2 and Nuxt Vite

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require("@postinumero/unplugin-formatjs/webpack")({
        /* options */
      }),
    ],
  },
};

// esbuild.config.js
import { build } from "esbuild";
import formatjs from "@postinumero/unplugin-formatjs/esbuild";

build({
  plugins: [formatjs()],
});

Options

babel

Passes options to babel-plugin-formatjs.

By default preserveWhitespace is true, and removeDefaultMessage is true in production.

Set options.babel to false to disable transforming source files.

See babel-plugin-formatjs for other available options.

processMessages

Passes options to process-messages.

By default, the application source code is expected to be in the app directory.

Set options.processMessages to e.g. { extract: { path: ["src"] } } to override the default options.

Set options.processMessages to false to disable message extraction and compilation.

noParser

By default react-intl without parser is used in production.
Set options.noParser to false to use react-intl with parser.