Back to Snowpack

@snowpack/plugin-build-script

plugins/plugin-build-script/README.md

3.8.51.3 KB
Original Source

@snowpack/plugin-build-script

A Snowpack plugin to build files in your application using any CLI tool. This plugin passes matching files as input to a custom CLI command and returns the output response as the build result. This is useful for connecting a custom CLI or when no Snowpack plugin exists for a favorite build tool.

Note: All Snowpack < v2.6 build:* scripts now use this plugin behind the scenes.

Usage:

bash
npm install @snowpack/plugin-build-script

Then add the plugin to your Snowpack config:

js
// snowpack.config.mjs

export default {
  plugins: [
    [
      '@snowpack/plugin-build-script',
      {
        input: ['.tsx'], // files to watch
        output: ['.tsx'], // files to export
        cmd: 'babel --filename $FILE', // cmd to run
      },
    ],
  ],
};

Plugin Options

NameTypeDescription
inputstring[]Array of extensions to watch for.
outputstring[]Array of extensions this plugin will output.
cmdstringCommand to run on every file matching input. Accepts the $FILE env var.