You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
webpack/plugins/manifest.js

44 lines
1.2 KiB

const Manifest = require('./../manifest.js')
const fs = require('fs')
/**
* Plugin for Manifest
*
* @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://git.node001.net/tiny-components/webpack.git
*
*/
class ManifestPlugin {
constructor(options) {
this._filename = options.filename,
this._context = options.context
}
apply(compiler) {
const pluginName = ManifestPlugin.name
// webpack module instance can be accessed from the compiler object,
// this ensures that correct version of the module is used
// (do not require/import the webpack or any symbols from it directly).
const { webpack } = compiler
// Compilation object gives us reference to some useful constants.
const { Compilation } = webpack
// create manifest object
const manifest = new Manifest(this._filename, this._context)
compiler.hooks.afterEmit.tapAsync(pluginName, (compilation, callback) => {
const stats = compilation.getStats().toJson()
manifest.run(stats)
callback()
})
}
}
module.exports = ManifestPlugin