Home

Awesome

rsbuild-plugin-generate-file

npm npm npm

rsbuild-plugin-generate-file is a rsbuild plugin which generate static file and write them to dist folder after packaging.

Usage

Install dev dependency :

yarn add rsbuild-plugin-generate-file -D
npm install rsbuild-plugin-generate-file -D

Add plugin to your rsbuild.config.ts :

// rsbuild.config.ts
import { pluginGenerateFile } from 'rsbuild-plugin-generate-file';

export default {
  plugins: [
    pluginGenerateFile([{
      type: 'json',
      output: './output.txt',
      data: {
        foo: 'bar'
      }
    }])
  ]
}

Here are the available options for configuration:

NameDescriptionOptionsDefaults
typeSpecifies the format type of the generated file.json yaml templatejson
outputDefines the path to the output file that the plugin will generate. This path is relative to the dist folder.-./output.txt
templateSpecifies the path to the template file. Supports ejs format template. This option is available when type is set to template.--
dataSpecifies the data to be used in the generated file or to be passed into the template.--
contentTypeDefines the Content-Type response returned from the dev server. If left empty, it will be inferred from the output path extension.--

In dev mode, plugin will mock file by dev server. See localhost:8080/__generate_file_list/ for more detail.

Credits

This plugin was inspired by Alicevia/vite-plugin-generate-config-into-dist and sumy7/vite-plugin-generate-file and antfu/vite-plugin-inspect

License

MIT