Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
michaelprescott opened this issue Jan 2, 2019 · 0 comments
Open

Comments

@michaelprescott
Copy link

michaelprescott commented Jan 2, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant