output.copy

  • Type: Rspack.CopyRspackPluginOptions | Rspack.CopyRspackPluginOptions['patterns']
  • Default: undefined

Copies the specified file or directory to the dist directory, implemented based on rspack.CopyRspackPlugin.

Please refer to the configuration options here: rspack.CopyRspackPlugin.

Example

Copy files from ./src/assets to the ./dist directory:

export default {
  output: {
    copy: [
      // `./src/assets/image.png` -> `./dist/image.png`
      { from: './src/assets' },
    ],
  },
};

Copy files from ./src/assets to the ./dist/assets directory:

export default {
  output: {
    copy: [
      // `./src/assets/image.png` -> `./dist/assets/image.png`
      { from: './src/assets', to: 'assets' },
    ],
  },
};

When copying files from the public directory to the dist directory during a production build, the public/someDir directory will be ignored:

export default {
  output: {
    copy: [{ from: './public', globOptions: { ignore: ['**/someDir/**'] } }],
  },
  server: {
    publicDir: {
      copyOnBuild: false,
    },
  },
};