Skip to content

Commit 932c221

Browse files
committed
Fix webpack config (by stealing Dave's config)
Without doing something like this it's hard to use `yarn link`ed resources.
1 parent 3e324f6 commit 932c221

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

webpack.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ module.exports = (env, argv) => {
2121
development['devtool'] = 'eval-source-map';
2222
}
2323

24+
// Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early so we
25+
// don't have to call them over and over. We also resolve to the package.json instead of the src
26+
// directory so we don't have to rely on a index.js or similar file existing.
27+
const reactSdkSrcDir = path.resolve(path.join(require.resolve("matrix-react-sdk/package.json"), '..', 'src'));
28+
const jsSdkSrcDir = path.resolve(path.join(require.resolve("matrix-js-sdk/package.json"), '..', 'src'));
29+
2430
return {
2531
...development,
2632

@@ -117,8 +123,8 @@ module.exports = (env, argv) => {
117123
// run them through babel. Because the path tested is the resolved, absolute
118124
// path, these could be anywhere thanks to yarn link. We must also not
119125
// include node modules inside these modules, so we add 'src'.
120-
if (f.includes(path.join('matrix-js-sdk', 'src'))) return true;
121-
if (f.includes(path.join('matrix-react-sdk', 'src'))) return true;
126+
if (f.startsWith(reactSdkSrcDir)) return true;
127+
if (f.startsWith(jsSdkSrcDir)) return true;
122128

123129
// but we can't run all of our dependencies through babel (many of them still
124130
// use module.exports which breaks if babel injects an 'include' for its

0 commit comments

Comments
 (0)