Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

stats is ignored #70

Closed
1 of 3 tasks
donaldpipowitch opened this issue Mar 21, 2018 · 13 comments · Fixed by #91
Closed
1 of 3 tasks

stats is ignored #70

donaldpipowitch opened this issue Mar 21, 2018 · 13 comments · Fixed by #91

Comments

@donaldpipowitch
Copy link

  • Operating System: Win 10
  • Node Version: 9.x
  • NPM Version: 5.x
  • webpack Version: 4.2
  • webpack-serve Version: 0.2

This issue is for a:

  • bug
  • feature request
  • modification request

Code

CLI Command
  $ webpack-serve ... # remove this block if using the API
webpack.config.js
  {
    // ...
    stats: 'none'
  }

Expected Behavior

Respect the setting. Don't show logs.

Actual Behavior

Default logs are shown.

How Do We Reproduce?

Added stats: 'none' to https://github.com/donaldpipowitch/pipo-scripts/blob/master/packages/pipo-scripts/build.js#L61, but it uses yarn 🙈

@shellscape
Copy link
Contributor

@donaldpipowitch which log output is being shown? paste?

@donaldpipowitch
Copy link
Author

@shellscape
Copy link
Contributor

Thanks for the output in the README there, very helpful. That's going to be an issue with webpack-dev-middleware unfortunately. There may be something wonky going on there. For poops and giggles, can you reproduce that in webpack-dev-server? This is the only thing we're doing with stats in this repo:

webpack-serve/index.js

Lines 46 to 61 in f1aad58

const done = (stats) => {
const json = stats.toJson();
if (stats.hasErrors()) {
bus.emit('compiler-error', json);
}
if (stats.hasWarnings()) {
bus.emit('compiler-warning', json);
}
};
if (options.compiler.hooks) {
options.compiler.hooks.done.tap('WebpackServe', done);
} else {
options.compiler.plugin('done', done);
}

@shellscape
Copy link
Contributor

@donaldpipowitch ping

@donaldpipowitch
Copy link
Author

Hi! Sorry, I'm currently sick. I think I need some more days before I can look into that again. Thanks. ✌️

@shellscape
Copy link
Contributor

No worries man. Hope you feel better quickly!

@donaldpipowitch
Copy link
Author

No problem. Thank you :)

@jdart
Copy link

jdart commented Mar 29, 2018

If I add options.dev = { stats: 'minimal' }; before the getServer call stats are minimal... maybe passing stats should happen in options.js?

    if (configs[0].stats) {
      options.dev.stats = configs[0].stats;
    }

@shellscape
Copy link
Contributor

shellscape commented Mar 29, 2018

@jdart https://github.com/webpack/webpack-dev-middleware/#stats

I'm not sure you're following the relationship between webpack-serve, koa-webpack, and webpack-dev-middleware. If you've got { dev: { stats } } defined in options, then it should be passed straight along to koa-webpack here

dev: options.dev,
, which then passes it right along to webpack-dev-middleware.

From koa-webpack for reference: https://github.com/shellscape/koa-webpack/blob/795986b0343ba540effc085a06f9c03a62d113a0/index.js#L85

@jdart
Copy link

jdart commented Mar 29, 2018

For sure I'm fuzzy on the relationship. I'm using a webpack.config.js that looks like the one from @donaldpipowitch, and running webpack-serve on the command line. Webpack won't allow a key "dev" - configuration has an unknown property 'dev'. I tried running webpack-serve --dev '{"stats": "minimal"}' but it fails with TypeError: Cannot create property 'publicPath' on string '{"stats": "minimal"}'.

@jdart
Copy link

jdart commented Mar 29, 2018

I found creating a .serverc.json with the below content works:

{
    "dev": {
        "stats": "minimal",
        "publicPath": "/"
    }
}

Adding the below to webpack.config.js also works:

    serve: {
        dev: {
            stats: 'minimal'
        }
    },

@shellscape
Copy link
Contributor

shellscape commented Mar 29, 2018

Typically folks will only add serve to their webpack config if they're in a dev environment. eg:

module.exports = {
  ... <webpack config> ...
}

if (process.env.NODE_ENV === 'development') {
  // or process.env.WEBPACK_SERVE === true
  module.exports.serve = {
    ... <serve config> ...
  }
}

You can also try creating serve.config.js (or you can put this in .serverc + json as an alternative).

module.exports = {
  { stats: 'minimal' }
};

It looks like we need a proper CLI test for passing the dev and hot options, as it looks like there's some JSON parsing that could be missing. (passing those two on the command line doesn't happen that frequently).

@donaldpipowitch
Copy link
Author

In case anyone sees this issue from googling it, since webpack-serve@^2.0.0 the webpack config should look like this:

{
  serve: {
    devMiddleware: {
      stats: {}
    }
  }
}

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

Successfully merging a pull request may close this issue.

3 participants