Skip to content

Fails when using multiple entry points and html-webpack-plugin #114

Open
@michaelprescott

Description

@michaelprescott

I love this plugin! I was working on something similar when I stumbled across it when researching webpack performance tips. It's exactly what I need, except it's breaking down a bit on some of my projects.

The output monitor/stats.json is invalid JSON when webpack config has multiple entry points and multiple html-webpack-plugin configurations.

Abbreviated webpack config:

{
    "stats": { "all": true },
    "entry": { 
        "index": "./src/index.ts", 
        "introduction": "./src/introduction.ts" 
    },
    "output": {
        "filename": "[name].js",
        "path": "/dist"
    },
    "plugins": [
        new HtmlWebpackPlugin({...}), 
        new HtmlWebpackPlugin({...}), 
        new WebpackMonitor({
            capture: true,
            launch: true,
        })
    ]
}

Throws error:
SyntaxError: Unexpected token { in JSON at position 11860
at JSON.parse ()
at MonitorStats.apply (/node_modules/webpack-monitor/monitor.js:90:19)

Two blocks of stats are generated and written to the same stats.json:

  {
    "timeStamp": 1546382960936,
    "time": 681,
    "hash": "57c5490ec58f180b3289",
    "errors": [],
    "size": 7574,
    "assets": [
      {
        "name": "index.html",
        "chunks": [],
        "size": 197
      }...
]  {   /* <<<<<----------- breakdown here */
    "timeStamp": 1546384890703,
    "time": 1010,
    "hash": "16e0f2209281944a260c",
    "errors": [],
    "size": 15750,
    "assets": [
      {
        "name": "introduction.html",
        "chunks": [],
        "size": 273
      }...
]

Maybe wrap the multiple stat blocks in an array and assign the array to a prop so that the viewer could handle the file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions