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

webpack-pathed-assets-manifest-plugin

v4.0.1

Published

Create manifest file use their pathname

Downloads

18

Readme

webpack-pathed-assets-manifest-plugin

v2.0及以上版本仅支持webpack@4。如果你在使用webpack@3,请使用 1.x 版本代替:npm install webpack-pathed-assets-manifest-plugin@1

创建资源清单文件,使用他们的路径当作 key,以方便 server-render 项目映射资源文件路径到打包后的文件。

注:该插件无法替代 webpack-manifest-plugin。它仅仅处理入口文件中 require 的资源文件,例如图片等。

解决的问题

如下文件结构,模块 A 和 B 下的出现了名称同为 logo.png 的不同图片文件:

    app/
    |- /A
      |- index.js
      |- logo.png
      |- title.png
    |- /B
      |- index.js
      |- logo.png

我们使用 webpack-manifest-plugin 这种插件,生成的清单文件,会类似:

{
    "logo.png": "logo.d5ae6b8d.png",
    "title.png": "title.531a2154.png"
}

很明显可以看出,少了个 logo.png 文件的记录。也就是说,不同模块下的同名文件,在清单文件中会相互覆盖,导致生成的清单文件有丢失文件记录。

而通过本插件,可以生成:

{
    "app/A/logo.png": "logo.d5ae6b8d.png",
    "app/A/title.png": "title.531a2154.png",
    "app/B/logo.png": "logo.423a075.png"
}

完美保留了所有的文件索引。

安装

npm install --save-dev webpack-pathed-assets-manifest-plugin

使用

var PathedManifestPlugin = require('webpack-pathed-assets-manifest-plugin');

module.exports = {
    // ...
    plugins: [
        new PathedManifestPlugin({
            filename: 'pathed.manifest.json',
            map: null, // 可以传function,自定义filename和pathname,默认pathname为相对项目根目录的相对路径
            filter: null, // 可以传function,自定义过滤的文件
            assetFilename: '[name].[hash].[ext]' // 静态文件的命名模版,默认为文件后缀前是hash值,如果你的文件命名规则不是这样,可以修改该模板。例如:asset-[name].[hash:8].[ext]
        })
    ]
};