Skip to content

Commit 6387915

Browse files
committed
Use resolve.root when resolving loaders
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 ```
1 parent a387663 commit 6387915

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/utils/webpack.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,12 @@ module.exports = (program, directory, stage, webpackPort = 1500, routes = []) =>
363363
devtool: devtool(),
364364
output: output(),
365365
resolveLoader: {
366+
root: [
367+
path.resolve(directory, 'loaders'),
368+
path.resolve(__dirname, '..', 'loaders'),
369+
],
366370
modulesDirectories: [
367-
`${directory}/node_modules`,
368-
`${directory}/loaders`,
369-
`${__dirname}/../../node_modules`,
370-
`${__dirname}/../loaders`,
371+
'node_modules',
371372
],
372373
},
373374
plugins: plugins(),

0 commit comments

Comments
 (0)