Skip to content

Commit

Permalink
Use resolve.root when resolving loaders
Browse files Browse the repository at this point in the history
This is a performance optimization recommended in gatsbyjs#280

There are a lot less loaders than general modules, so the performance
gain is minimal, but every second counts.

---
`gatsby-starter-blog`

Before:
```
Command being timed: "gatsby build"
User time (seconds): 24.29
System time (seconds): 2.83
Percent of CPU this job got: 110%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:24.56
```

After:
```
Command being timed: "gatsby build"
User time (seconds): 23.78
System time (seconds): 2.80
Percent of CPU this job got: 110%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:24.05
```

---
`kyleamathews/blog`

Before:
```
Command being timed: "gatsby build"
User time (seconds): 29.84
System time (seconds): 2.81
Percent of CPU this job got: 110%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:29.59

After:
```
Command being timed: "gatsby build"
User time (seconds): 26.70
System time (seconds): 2.79
Percent of CPU this job got: 112%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:26.30
```
  • Loading branch information
benstepp committed May 22, 2016
1 parent a387663 commit 6387915
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,12 @@ module.exports = (program, directory, stage, webpackPort = 1500, routes = []) =>
devtool: devtool(),
output: output(),
resolveLoader: {
root: [
path.resolve(directory, 'loaders'),
path.resolve(__dirname, '..', 'loaders'),
],
modulesDirectories: [
`${directory}/node_modules`,
`${directory}/loaders`,
`${__dirname}/../../node_modules`,
`${__dirname}/../loaders`,
'node_modules',
],
},
plugins: plugins(),
Expand Down

0 comments on commit 6387915

Please sign in to comment.