Skip to content

Commit

Permalink
Update Webpack config location for Dev and Prod
Browse files Browse the repository at this point in the history
  • Loading branch information
hckhanh committed Dec 24, 2018
1 parent c4e8dd4 commit 76c6929
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 12 deletions.
146 changes: 139 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/craco/lib/cra.js
Expand Up @@ -12,7 +12,7 @@ function resolveScriptsFilePath(fileName) {
}

function overrideModule(modulePath, newModule) {
require.cache[modulePath].exports = newModule;
require.cache[modulePath].exports = () => newModule;

log(`Overrided require cache for module: ${modulePath}`);
}
Expand All @@ -22,15 +22,15 @@ const craPaths = require(resolveConfigFilePath("paths.js"));
/************ Webpack Dev Config *******************/

function getWebpackDevConfigPath() {
return resolveConfigFilePath("webpack.config.dev");
return resolveConfigFilePath("webpack.config");
}

function loadWebpackDevConfig() {
const filepath = getWebpackDevConfigPath();

log("Found Webpack dev config at: ", filepath);

return require(filepath);
return require(filepath)("development");
}

function overrideWebpackDevConfig(newConfig) {
Expand All @@ -42,15 +42,15 @@ function overrideWebpackDevConfig(newConfig) {
/************ Webpack Prod Config *******************/

function getWebpackProdConfigPath() {
return resolveConfigFilePath("webpack.config.prod");
return resolveConfigFilePath("webpack.config");
}

function loadWebpackProdConfig() {
const filepath = getWebpackProdConfigPath();

log("Found Webpack prod config at: ", filepath);

return require(filepath);
return require(filepath)("production");
}

function overrideWebpackProdConfig(newConfig) {
Expand Down

0 comments on commit 76c6929

Please sign in to comment.