question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slow incremental webpack build times

See original GitHub issue

I understand that this might not be the right place to report this issue, but I thought I’d post it here first to see if anyone else has more context.

We have a fairly large React app where we use webpack to compile our application.js bundle. Stylesheets are resolved using sass-loader, and components import their own stylesheets, like this:

const styles = require('./index.scss');

const Component = React.createClass({
  render() {
    return <div className={styles.
  }
});

To share configuration between the components and sass files (we use scss), we have a shared_config.json file with some key-value settings. In the past, we’ve used a manual script to generate a shared_config.scss file that we then use in our scss files. Yesterday, (thanks to https://github.com/Updater/node-sass-json-importer/pull/13) we switched to directly importing the json file, through the help of node-sass-json-import. That worked out well, the only problem is that our incremental build times for our webpack bundle went up from ~2.5 seconds to ~12 seconds. An incremental build happens any time a .scss or .js* file is saved. I’ve spent some time to bisect our git history to make sure that it was in fact adding this to our webpack.config.js that introduced the performance regression:

  sassLoader: {
    importer: require('node-sass-json-importer'),
    includePaths: [
      path.resolve('./app/assets/stylesheets'),
    ],
  }

Any ideas what could be the problem? I’m suspecting that node-sass/libsass isn’t being smart enough with custom importers (after all, node-sass warns about this being an experimental feature).

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
JaZocommented, May 10, 2017

I’ve done some profiling as @pmowrer suggested and put some logs at the beginning and end of the importer. The timing difference is only ~5ms! These results do not seem to indicate that the speed decrease is caused by node-sass-json-importer itself, but rather by something deeper in the stack. I’ll try to see if I can dig a little deeper.

N.B. My json is very simple: {"screen-xs": "480px", "screen-sm": "768px", "screen-m": "900px", "screen-l": "1100px", "screen-xl": "1300px", "screen-xxl": "1600px", "screen-mega": "1900px"}

1reaction
donnysimcommented, Sep 18, 2018

I just removed this package, because it forces recompilation of the styles every time something changes, even though it does not touch styles themselves. So an incremental compilation slows down from ~800ms to 3-5s.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build Performance - webpack
This guide contains some useful tips for improving build/compilation performance. General. The following best practices should help, whether you're running ...
Read more >
How to boost the speed of your webpack build?
Depending on the machine on which the build was launched, it took between 5 and 12 minutes. It is not possible to have...
Read more >
Webpack incremental builds are slow · Issue #616 - GitHub
On my machine, incremental builds in dev mode take anywhere from 1.5s - 5s. I'm going to spend some time toying with webpack...
Read more >
Understanding why our build got 15x slower with Webpack 5
We don't do this very often in a typical day, but it turns out that having to wait for two minutes plus, even...
Read more >
Keep webpack Fast: A Field Guide for Better Build Performance
Keep webpack Fast: A Field Guide for Better Build Performance · In the land before time · Before you begin, measure · Parallelize...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found