Giter VIP home page Giter VIP logo

assets-manifest-plugin's Introduction

assets-manifest-plugin

A webpack plugin for entry assets manifest. 一个生成入口资源清单的webpack插件

Travis (.org) branch npm GitHub

安装

npm i -D assets-manifest-plugin

# or

yarn add -D assets-manifest-plugin

配置

webpack.config.js

const AssetsManifestPlugin = require('assets-manifest-plugin');

module.exports = {
  // ...
  plugins: [
    new AssetsManifestPlugin({
      filename: 'manifest.js'
    })
  ]
}

打包完成后会输出类似下面的一个文件:

dist/manifest.js

(function(root, factory) {
  if (typeof exports === 'object' && typeof module === 'object') {
    module.exports = factory();
  } else if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof exports === 'object') {
    exports['ASSETS_MANIFEST'] = factory();
  } else {
    root['ASSETS_MANIFEST'] = factory();
  }
})(typeof window !== 'undefined' ? window : this, function() {
  return {
    "main": {
      "js": [
        "js/runtime.6b509e0d.js",
        "js/vendors.066af6ec2.js",
        "js/main.5f10cd1d.js"
      ],
      "css": [
        "css/vendors.ac89822e.css",
        "css/main.5ceab323.css"
      ]
    }
  }
});

配置选项

entries

  • 类型: 'all' | Array<string>
  • 默认: 'all'
  • 描述: 需要生成资源清单的 entry 名,如果设置为 'all',表示生成全部入口资源清单

publicPath

  • 类型: string
  • 默认: null
  • 描述: 在生成的资源清单路径前加的一段路径,如果该项未配置,则会去使用 output.publicPath 的值

filename

  • 类型: string
  • 默认: 'manifest.js'
  • 描述: 生成的入口清单文件名(可以带路径),如果是文件格式是 .js,这会输出一个 UMD 模块文件,如果文件格式是 .json,则输出一个 JSON 文件,推荐生成 UMD 模块

minify

  • 类型: 'auto' | boolean
  • 默认: 'auto'
  • 描述: 是否压缩生成的资源清单文件,如果设置为 'auto',表示根据 optimization.minimize 自动判断是否需要压缩

globalName

  • 类型: string
  • 默认: 'ASSETS_MANIFEST'
  • 描述: 生成 UMD 模块的全局变量名

disabled

  • 类型: boolean
  • 默认: false
  • 描述: 是否禁用插件

shouldEmit

  • 类型: boolean
  • 默认: true
  • 描述: 是否将入口资源清单输出到文件

merge

  • 类型: boolean
  • 默认: false
  • 描述: 是否合并之前的资源清单数据(一般用于多个webpack任务打包时共用一份清单文件)

onEmit

  • 类型: (manifest, mergedManifest) => void
  • 默认: null
  • 描述: 当生成入口资源清单时,执行回调。回调参数是一个包含资源清单的 JSON 对象

devServerAutoPublicPath

  • 类型: boolean
  • 默认: true
  • 描述: 当前是 devServer 模式时,自动设置 publicPath (http://[ip]:[port]/[publicPath])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.