Skip to content

Add override configs #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ template/src/__tests__/__snapshots__/
lerna-debug.log
npm-debug.log
/.changelog
.idea
3 changes: 3 additions & 0 deletions config/webpack.config.dev.override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function overrideDevConfig(config) {
return config;
}
3 changes: 3 additions & 0 deletions config/webpack.config.prod.override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function overrideProdConfig(config) {
return config;
}
4 changes: 2 additions & 2 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var env = getClientEnvironment(publicUrl);
// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
// The production configuration is different and lives in a separate file.
module.exports = {
module.exports = require('./webpack.config.dev.override')({
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
devtool: 'cheap-module-source-map',
Expand Down Expand Up @@ -235,4 +235,4 @@ module.exports = {
net: 'empty',
tls: 'empty'
}
};
});
13 changes: 13 additions & 0 deletions packages/react-scripts/config/webpack.config.dev.override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var overrideConfig = function(config) {
return config;
};

// @remove-on-eject-begin
var path = require('path');
var overrideConfigPath = path.resolve(process.cwd(), 'config/webpack.config.dev.override.js');
overrideConfig = require(overrideConfigPath);
// @remove-on-eject-end

module.exports = function devConfigOverride(config) {
return overrideConfig(config);
};
4 changes: 2 additions & 2 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if (env['process.env'].NODE_ENV !== '"production"') {
// This is the production configuration.
// It compiles slowly and is focused on producing a fast and minimal bundle.
// The development configuration is different and lives in a separate file.
module.exports = {
module.exports = require('./webpack.config.prod.override')({
// Don't attempt to continue if there are any errors.
bail: true,
// We generate sourcemaps in production. This is slow but gives good results.
Expand Down Expand Up @@ -277,4 +277,4 @@ module.exports = {
net: 'empty',
tls: 'empty'
}
};
});
13 changes: 13 additions & 0 deletions packages/react-scripts/config/webpack.config.prod.override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var overrideConfig = function(config) {
return config;
};

// @remove-on-eject-begin
var path = require('path');
var overrideConfigPath = path.resolve(process.cwd(), 'config/webpack.config.prod.override.js');
overrideConfig = require(overrideConfigPath);
// @remove-on-eject-end

module.exports = function prodConfigOverride(config) {
return overrideConfig(config);
};
2 changes: 2 additions & 0 deletions packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ prompt(
path.join('config', 'paths.js'),
path.join('config', 'polyfills.js'),
path.join('config', 'webpack.config.dev.js'),
path.join('config', 'webpack.config.dev.override.js'),
path.join('config', 'webpack.config.prod.js'),
path.join('config', 'webpack.config.prod.override.js'),
path.join('config', 'jest', 'cssTransform.js'),
path.join('config', 'jest', 'fileTransform.js'),
path.join('scripts', 'build.js'),
Expand Down