Skip to content

Commit

Permalink
Add resolveLoaders config to locate postcss-loader
Browse files Browse the repository at this point in the history
+ Resolves "module not found" error when attempting a build in an app with dev-utils as a dep and postcss-loader as a transitive dep.
+ Recent bump in postcss-related versions caused yarn to start installing the loader within the nested node_modules dir, requiring this hint to allow webpack to find it again.
  • Loading branch information
amcclain committed Dec 1, 2020
1 parent 4029912 commit a3b523d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions configureWebpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ function configureWebpack(env) {
path.resolve(hoistPath, 'node_modules') :
null;

// Also get a handle on the nested @xh/hoist-dev-utils/node_modules path - dev-utils dependencies
// (namely loaders) can be installed here due to the vagaries of node module version / conflict resolution.
const devUtilsNodeModulesPath = path.resolve(basePath, 'node_modules/@xh/hoist-dev-utils/node_modules');

// Resolve app entry points - one for each file within src/apps/ - to create bundle entries below.
const appDirPath = path.resolve(srcPath, 'apps'),
apps = fs
Expand Down Expand Up @@ -272,6 +276,13 @@ function configureWebpack(env) {
extensions: ['*', '.js', '.jsx', '.json']
},

// Ensure Webpack can find loaders installed both within the top-level node_modules dir for
// an app that's building (standard case) or nested within dev-utils node_modules (in case
// of version conflict - triggered for us in Dec 2020 by postcss-loader version bump).
resolveLoader: {
modules: ['node_modules', devUtilsNodeModulesPath]
},

stats: stats,

module: {
Expand Down

0 comments on commit a3b523d

Please sign in to comment.