0.4.0 • Published 5 years ago

asset-list-webpack-plugin v0.4.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

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

NameTypeDefaultDescription
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.

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago