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 🙏

© 2024 – Pkg Stats / Ryan Hefner

yyl-copy-webpack-plugin

v1.0.8

Published

过滤规则使用 [https://www.npmjs.com/package/matcher](matcher) 插件

Downloads

47

Readme

yyl-copy-webpack-plugin

过滤规则使用 https://www.npmjs.com/package/matcher 插件

USAGE

const YylCopyWebpackPlugin = require('yyl-copy-webpack-plugin')

const wConfig = {
  plugins: [
    new YylCopyWebpackPlugin({
      /** 拷贝信息 */
      files: [
        {
          from: 'src/source',
          to: 'dist/assets/source',
          matcher: ['*.html', '!**/.*']
        },
        {
          from: 'src/source',
          to: 'dist/assets/source',
          matcher: ['!*.html', '!**/.*']
        }
      ],
      /** 文件名 默认为 [name]-[hash:8].[ext] */
      filename: '[name]-[hash:8].[ext]',
      /** 是否压缩 */
      minify: true,
      /** log 路径的 相对路径 */
      logBasePath: __dirname,
      /** 基本路径, 会用于 resolve files 里面的路径 */
      basePath: __dirname
    })
  ]
}

hooks

let YylCopyWebpackPlugin
try {
  YylCopyWebpackPlugin = require('yyl-copy-webpack-plugin')
} catch (e) {
  if (!(e instanceof Error) || e.code !== 'MODULE_NOT_FOUND') {
    throw e
  }
}

const PLUGIN_NAME = 'your_plugin'
class ExtPlugin {
  apply(compiler) {
    const IPlugin = YylCopyWebpackPlugin
    if (IPlugin) {
      compiler.hooks.compilation.tap(IPlugin.getName(), (compilation) => {
        IPlugin.getHooks(compilation).beforeCopy.tapAsync(PLUGIN_NAME, (obj, done) => {
          console.log('hooks.beforeConcat(obj, done)', 'obj:', obj)
          done(null, obj)
        })
        IPlugin.getHooks(compilation).afterCopy.tapAsync(PLUGIN_NAME, (obj, done) => {
          console.log('hooks.afterConcat(obj, done)', 'obj:', obj)
          done(null, obj)
        })
      })
    }
  }
}

ts

/// <reference types="node" />
import { Compilation, Compiler } from 'webpack'
import {
  AssetsInfo,
  YylWebpackPluginBaseOption,
  YylWebpackPluginBase
} from 'yyl-webpack-plugin-base'
export interface AssetsSource {
  size(): number
  map(options?: any): Object
  sourceAndMap(
    options?: any
  ): {
    source: string | Buffer
    map: Object
  }
  updateHash(hash: any): void
  source(): string | Buffer
  buffer(): Buffer
}
export declare type FileInfo = Required<AssetsInfo>
export interface CopyInfo {
  /** 原地址 */
  from: string
  /** 目标地址 */
  to: string
  /** 沿用 matcher 规则 */
  matcher?: string[]
  /** 文件名 默认为 [name]-[hash:8].[ext] */
  filename?: string
}
export interface YylCopyWebpackPluginOption extends Pick<YylWebpackPluginBaseOption, 'context'> {
  /** 拷贝信息 */
  files?: CopyInfo[]
  /** 是否压缩 */
  minify?: boolean
  /** 压缩是否支持 ie8 默认 false */
  ie8?: boolean
  /** log 路径的 相对路径 */
  logContext?: string
}
export default class YylCopyWebpackPlugin extends YylWebpackPluginBase {
  static getHooks(compilation: Compilation): any
  static getName(): string
  option: Required<YylCopyWebpackPluginOption>
  constructor(option?: YylCopyWebpackPluginOption)
  formatSource(fileInfo: FileInfo): Promise<FileInfo>
  apply(compiler: Compiler): Promise<void>
}