asset-list-webpack-plugin

0.4.0 • Public • Published

npm

Asset List Webpack Plugin

This is a webpack plugin that outputs a simple list of generated assets with your webpack bundle.

Install

npm install --save-dev asset-list-webpack-plugin

Usage

The plugin will generate a JSON file that lists all of the generated assets from the webpack bundle process. The format of this list can be changed by setting different options.

Here is a basic example utilizing a simple config from the webpack Getting Started guide:

webpack.config.js

const path = require('path');
 
const AssetListWebpackPlugin = require('asset-list-webpack-plugin');
 
module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist')
  },
  plugins:  [new AssetListWebpackPlugin()]
};
 

This will generate a JSON file in the output path containing the following:

assets.json

[{
  "filename": "main.js",
  "name": "main",
  "type": "js"
}]

Additionally, you pass an object of options to change the format of the JSON file like so:

webpack.config.js

const path = require('path');
 
const AssetListWebpackPlugin = require('asset-list-webpack-plugin');
 
module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist')
  },
  plugins:  [new AssetListWebpackPlugin({
    name: 'file-list',
    format: 'object',
    key: 'name'
  })]
};
 

This will generate a JSON file that contains the following:

file-list.json

{
  "main": {
    "filename": "main.js",
    "name": "main",
    "type": "js"
  }
}

Options

Name Type Default Description
name {String} 'assets' Name of generated JSON file
format {'array'\|'object'} 'array' Format of generated JSON file
key {'filename'\|'name'\|'type'\|'fingerprint'} 'filename' Set keys for object formatted JSON file

License

This open source project is licensed under the MIT License.

Package Sidebar

Install

npm i asset-list-webpack-plugin

Weekly Downloads

148

Version

0.4.0

License

MIT

Unpacked Size

8.05 kB

Total Files

8

Last publish

Collaborators

  • mattlean