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

html-webpack-relative-assets-plugin

v1.0.0

Published

webpack html plugin 扩展插件,用于在多页面工程中页面index.html分文件夹存放时处理入口js文件路径

Downloads

5

Readme

html-webpack-relative-assets-plugin

webpack html plugin 扩展插件,用于在多页面工程中页面index.html分文件夹存放时处理入口js文件路径

在webpack打包多页面应用时,如果我们想要把页面的index.html文件放在以页面名称命名的文件夹中,那么就需要在page配置中配置一个相对路径的publicPath,来修正index.html中引用的js文件的路径。 本插件在webpack打包多页面应用时,会使用相对路径来自动修正index.html中引用的js文件的路径。 不会在../pageA/index.html文件中出现 ../pageA/index.js 的引用路径. ../pageA/index.html 文件中的入口js文件路径会自动修正为 ./index.js

install

  npm i --save-dev html-webpack-plugin html-webpack-relative-assets-plugin
  yarn add --dev html-webpack-plugin html-webpack-relative-assets-plugin

usage

const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackRelativeAssetsPlugin = require("html-webpack-relative-assets-plugin");
const sourceDir = 'src/pages'
const chunks = []
module.exports = {
  pages: {
    pageA: {
      minify: false,
      template: `${sourceDir}/index.html`,
      entry: `${sourceDir}/pageA/main.js`,
      filename: `pageA/index.html`,
      // publicPath: '../',
      chunks: [...chunks, 'pageA']
    },
    pageB: {
      minify: false,
      template: `${sourceDir}/index.html`,
      entry: `${sourceDir}/pageB/main.js`,
      filename: `pageB/index.html`,
      // publicPath: '../',
      chunks: [...chunks, 'pageB']
    }
  },
  output: {
    path: __dirname + "/dist",
    filename: '[name]/[name].[hash].js', // 使用了[name]/ 目录,如果不使用本插件,则需要配置publicPath来确保静态资源的正确引用
    chunkFilename: 'commonStatic/[name].[chunkhash].js'
  },
  plugins: [
    new HtmlWebpackPlugin(),
    new HtmlWebpackRelativeAssetsPlugin()
    ],
};