Skip to content

Commit abec63e

Browse files
author
Michal Svrček
committed
added possible modification of webpack config
1 parent 411347f commit abec63e

File tree

8 files changed

+24
-5
lines changed

8 files changed

+24
-5
lines changed

packages/babel-preset-react-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "babel-preset-react-app",
34
"version": "2.1.0",
45
"description": "Babel preset used by Create React App",

packages/create-react-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "create-react-app",
34
"version": "1.0.4",
45
"keywords": [

packages/eslint-config-react-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "eslint-config-react-app",
34
"version": "0.5.1",
45
"description": "ESLint configuration used by Create React App",

packages/react-dev-utils/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "react-dev-utils",
34
"version": "0.5.0",
45
"description": "Webpack utilities used by Create React App",

packages/react-scripts/config/paths.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ module.exports = {
8686
ownNodeModules: resolveApp('node_modules'),
8787
nodePaths: nodePaths,
8888
publicUrl: getPublicUrl(resolveApp('package.json')),
89-
servedPath: getServedPath(resolveApp('package.json'))
89+
servedPath: getServedPath(resolveApp('package.json')),
90+
webpackConfig: resolveApp('webpack.config.js'),
9091
};
9192

9293
// @remove-on-eject-begin
@@ -109,7 +110,8 @@ module.exports = {
109110
ownNodeModules: resolveOwn('../node_modules'),
110111
nodePaths: nodePaths,
111112
publicUrl: getPublicUrl(resolveApp('package.json')),
112-
servedPath: getServedPath(resolveApp('package.json'))
113+
servedPath: getServedPath(resolveApp('package.json')),
114+
webpackConfig: resolveApp('webpack.config.js'),
113115
};
114116

115117
// config before publish: we're in ./packages/react-scripts/config/
@@ -127,7 +129,8 @@ if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1)
127129
ownNodeModules: resolveOwn('../node_modules'),
128130
nodePaths: nodePaths,
129131
publicUrl: getPublicUrl(resolveOwn('../package.json')),
130-
servedPath: getServedPath(resolveOwn('../package.json'))
132+
servedPath: getServedPath(resolveOwn('../package.json')),
133+
webpackConfig: resolveApp('../template/webpack.config.js'),
131134
};
132135
}
133136
// @remove-on-eject-end

packages/react-scripts/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "react-scripts",
3-
"version": "0.9.0",
2+
"name": "@svrcekmichal/react-scripts",
3+
"version": "0.5.0",
44
"description": "Configuration and scripts for Create React App.",
55
"repository": "facebookincubator/create-react-app",
66
"license": "BSD-3-Clause",

packages/react-scripts/scripts/build.js

+6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ function printErrors(summary, errors) {
133133
// Create the production build and print the deployment instructions.
134134
function build(previousSizeMap) {
135135
console.log('Creating an optimized production build...');
136+
137+
if(fs.existsSync(paths.webpackConfig)) {
138+
console.log(chalk.yellow('Using modified webpack config!'));
139+
config = require(paths.webpackConfig)(config, false);
140+
}
141+
136142
webpack(config).run((err, stats) => {
137143
if (err) {
138144
printErrors('Failed to compile.', [err]);

packages/react-scripts/scripts/start.js

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ if (isSmokeTest) {
6161
}
6262

6363
function setupCompiler(host, port, protocol) {
64+
65+
if(fs.existsSync(paths.webpackConfig)) {
66+
console.log(chalk.yellow('WARNING! You are using modified webpack config!'));
67+
config = require(paths.webpackConfig)(config, true);
68+
}
69+
6470
// "Compiler" is a low-level interface to Webpack.
6571
// It lets us listen to some events and provide our own custom messages.
6672
compiler = webpack(config, handleCompile);

0 commit comments

Comments
 (0)