npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vite-file-move-plugin

v1.0.0

Published

Vite 插件:打包后移动指定文件/目录到目标位置,支持 glob/正则匹配

Readme

Vite File Move Plugin

一个灵活的 Vite 插件,用于在打包完成后将指定文件或目录移动到目标位置。支持 glob 模式匹配、正则表达式匹配和精确路径匹配,可自定义是否保留原目录结构。

功能特点

  • 支持多种匹配方式:glob 模式(如 public/*.js)、正则表达式(如 /\.js$/)和精确路径
  • 可控制是否保留源文件的目录结构
  • 支持强制覆盖目标文件
  • 支持移动前清空目标目录
  • 确保移动后源文件被删除(真正的"移动"而非"复制")
  • 详细的日志输出,便于调试

安装

npm install vite-file-move-plugin --save-dev
# 或
yarn add vite-file-move-plugin --dev

示例

import { defineConfig } from 'vite';
import fileMovePlugin from 'vite-file-move-plugin';

export default defineConfig({
  plugins: [
    // 其他插件...
    fileMovePlugin({
      source: [
        'dist/*.js',          // 匹配 dist 目录下的所有 JS 文件
        'dist/*.html',        // 匹配 dist 目录下的所有 HTML 文件
        /\.css$/              // 匹配所有 CSS 文件(正则表达式)
      ],
      target: 'dist/assets',  // 目标目录
      force: true,            // 强制覆盖已存在的文件
      preservePath: false,    // 不保留源文件的目录结构
      clean: false            // 移动前不清空目标目录
    })
  ]
});

参数说明

| 选项名 | 类型 | 默认值 | 说明 | |--------|------|--------|------| | source | string \| RegExp \| Array<string \| RegExp> | - | 必填,需要移动的文件或目录。可以是单个路径、正则表达式,或它们的数组 | | target | string | - | 必填,目标目录路径,默认是打包后的 dist/assets/js 目录 | | force | boolean | false | 是否强制覆盖目标位置已存在的文件 | | clean | boolean | false | 移动文件前是否清空目标目录 | | preservePath | boolean | false | 是否保留源文件的目录结构。设为 true 时,会将完整相对路径映射到目标目录 |