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 🙏

© 2026 – Pkg Stats / Ryan Hefner

webpack-copy-replace

v1.0.1

Published

webpack插件,处理打包后的文件,复制或者替换打包的内容

Readme

webpack-copy-replace

做这个插件是因为工作中有 测试环境 预上线环境 正式环境,这样每次打包都要手动去打包,很繁琐,作为一个程序员,能用代码处理的就绝不手动处理

用途

将webpack打包后的文件再次处理,如果替换文件中的某一些内容,或者直接就是复制一份出来

安装
  npm i webpack-copy-replace -D
  or
  yarn add webpack-copy-replace -D
  // vue.config.js or webpack config
  const webpackCopyReplace = require('webpack-copy-replace')

  module.exports = {
  configureWebpack: {
    plugins: [
      new webpackCopyReplace({/* API */})
    ]
  }
}
API
  • baseRetain { Boolean } 是否保留原始打包文件 -- 默认 true
  • basePath { String } 原始输出文件路径 -- 默认/base (PS: 输出的文件将会是在原有webpack的输出文件夹下 默认是在 dist/base)
  • error { Function } 替换错误回调
    • error({path, content, success})
      • path 对应 options 选项中的 replacePath
      • content 文件内容
      • success 处理完成回调
        • success(content) { content } 回调传参处理后的数据
  • options { Array[Object] } 复制文件参数配置
    • replaceFile { Array[String] } 需要替换的文件类型 -- 如果不传,不会去替换任何内容
    • replacePath { String } 替换后的文件输出目录 -- 不传输出路径的话是不会输出替换后的文件
    • exclude { Array[String] } 排除替换的文件
    • rules { Array[Object] } 排除替换的文件
      • reg { RegExp } // 被替换的内容
      • value { String } // 替换后的内容
完整配置
{
    baseRetain: true, // 是否保留原始打包文件 -- 默认 true
    basePath: '/prod', // 原始输出文件路径 -- 默认 /base
    // 替换错误回调
    error: ({ path, content, success }) => {
      success(content)
    },
    // 复制文件配置
    options: [{
      replaceFile: ['js', 'html'], // 需要替换的文件类型 -- 如果不传的话,不会去替换任何内容
      replacePath: '/stag1', // 替换后的文件输出目录 -- 不写输出路径的话是不会输出替换后的文件
      // 排除的文件
      exclude: [
        'abc.js'
      ],
      // 替换规则
      rules: [
        {
          reg: new RegExp('test', 'g'), // 需要替换的内容
          value: 'abc' // 替换后的值
        }
      ]
    }, {
      replaceFile: ['js', 'html'], // 需要替换的文件类型 -- 如果不传的话,不会去替换任何内容
      replacePath: '/stag2', // 替换后的文件输出目录 -- 不写输出路径的话是不会输出替换后的文件// 排除的文件
      exclude: [
        'abcdefg.js'
      ],
      // 替换规则
      rules: [
        {
          reg: new RegExp('abc', 'g'), // 需要替换的内容
          value: 'def' // 替换后的值
        }
      ]
    }]
  }