Webpack-encore: How to use webpack --profile option in symfony-encore

Created on 28 Dec 2017  路  3Comments  路  Source: symfony/webpack-encore

How do you enable --profile option as described in this doc http://webpack.github.io/docs/build-performance.html#hints-from-build-stats

I'd like to improve my build by reducing time

HasPR

Most helpful comment

Hi @mstrom,

If you want the profiling stats to be displayed in your console you'll need to modify the generated webpack config manually since Encore silences most outputs:

// webpack.config.js
const Encore = require('@symfony/webpack-encore');

Encore
  .setOutputPath('build/')
  .setPublicPath('/')
  // (...)
;

// Generate the config
const config = Encore.getWebpackConfig();

// Use default `stats` options
delete config.stats;

// Export the config (do NOT call `getWebpackConfig()` again)
module.exports = config;

You should then be able to call yarn run encore production --profile.

Now, if you want to use these stats in profiling tools you'll also need the --json option. That one won't work right now because of another issue (see #204) but that should be fixed once #215 is merged.

Anyway, maybe we should also fallback to the default stats options when Encore is called with the --profile option though, WDYT @weaverryan?

All 3 comments

Hi @mstrom,

If you want the profiling stats to be displayed in your console you'll need to modify the generated webpack config manually since Encore silences most outputs:

// webpack.config.js
const Encore = require('@symfony/webpack-encore');

Encore
  .setOutputPath('build/')
  .setPublicPath('/')
  // (...)
;

// Generate the config
const config = Encore.getWebpackConfig();

// Use default `stats` options
delete config.stats;

// Export the config (do NOT call `getWebpackConfig()` again)
module.exports = config;

You should then be able to call yarn run encore production --profile.

Now, if you want to use these stats in profiling tools you'll also need the --json option. That one won't work right now because of another issue (see #204) but that should be fixed once #215 is merged.

Anyway, maybe we should also fallback to the default stats options when Encore is called with the --profile option though, WDYT @weaverryan?

@Lyrkan I think detecting the --profile option makes sense.

Hmm, yea, makes sense.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JohnnyEvo picture JohnnyEvo  路  3Comments

BackEndTea picture BackEndTea  路  3Comments

powerlimit picture powerlimit  路  4Comments

iammichiel picture iammichiel  路  3Comments

o-alquimista picture o-alquimista  路  3Comments