Skip to content

Commit

Permalink
Merge pull request #11099 from mdn/webpack-cleanup
Browse files Browse the repository at this point in the history
chore(webpack): simplify our webpack config
  • Loading branch information
LeoMcA authored May 10, 2024
2 parents 9f9b11b + 8a8e7f6 commit 13c468d
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 893 deletions.
135 changes: 0 additions & 135 deletions client/config/modules.js

This file was deleted.

35 changes: 1 addition & 34 deletions client/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,7 @@ const publicUrlOrPath = getPublicUrlOrPath(

const buildPath = process.env.BUILD_PATH || "build";

const moduleFileExtensions = [
"web.mjs",
"mjs",
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
];

// Resolve file paths in the same order as webpack
const resolveModule = (resolveFn, filePath) => {
const extension = moduleFileExtensions.find((extension) =>
fs.existsSync(resolveFn(`${filePath}.${extension}`))
);

if (extension) {
return resolveFn(`${filePath}.${extension}`);
}

return resolveFn(`${filePath}.js`);
};
const moduleFileExtensions = ["mjs", "js", "ts", "tsx", "json", "jsx"];

// config after eject: we're in ./config/
const config = {
Expand All @@ -58,18 +33,10 @@ const config = {
appBuild: resolveApp(buildPath),
appPublic: resolveApp("public"),
appHtml: resolveApp("public/index.html"),
appIndexJs: resolveModule(resolveApp, "src/index"),
appPackageJson: resolveApp("../package.json"),
appSrc: resolveApp("src"),
appTsConfig: resolveApp("tsconfig.json"),
appJsConfig: resolveApp("jsconfig.json"),
yarnLockFile: resolveApp("../yarn.lock"),
testsSetup: resolveModule(resolveApp, "src/setupTests"),
proxySetup: resolveApp("src/setupProxy.js"),
appNodeModules: resolveApp("../node_modules"),
appWebpackCache: resolveApp("../node_modules/.cache"),
appTsBuildInfoFile: resolveApp("../node_modules/.cache/tsconfig.tsbuildinfo"),
swSrc: resolveModule(resolveApp, "src/service-worker"),
publicUrlOrPath,
libsPath: resolveApp("../libs"),
moduleFileExtensions,
Expand Down
Loading

0 comments on commit 13c468d

Please sign in to comment.