{"size": 1101, "ext": "js", "max_stars_repo_path": "webpack-plugins/asset-list-webpack-plugin.js", "max_stars_repo_name": "nate-luup/fe-seed", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "webpack-plugins/asset-list-webpack-plugin.js", "max_issues_repo_name": "nate-luup/fe-seed", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "webpack-plugins/asset-list-webpack-plugin.js", "max_forks_repo_name": "nate-luup/fe-seed", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.4666666667, "max_line_length": 52, "alphanum_fraction": 0.5222524977}
class AssetListWebpackPlugin {
  constructor(options) {
    console.log(options)
    this.filename = options.filename
  }
  apply(complier) {
    complier.hooks.emit.tapAsync(
      'AssetListWebpackPlugin',
      (compilation, callback) => {
        // console.log(compilation.assets)
        let cssList = []
        let jsList = []

        for (const filename in compilation.assets) {
          if (filename.indexOf('.css') !== -1) {
            cssList.push(filename)
          }
          if (filename.indexOf('.js') !== -1) {
            jsList.push(filename)
          }
        }
        const assetName = `${this.filename}.js`
        const finalSource = `
        const ${this.filename} = {
          cssList: ${JSON.stringify(cssList)},
          jsList : ${JSON.stringify(jsList)}
        }
      `
        compilation.assets[assetName] = {
          source: function() {
            return finalSource
          },
          size: function() {
            return finalSource.length
          },
        }

        callback()
      },
    )
  }
}

module.exports = AssetListWebpackPlugin
