Skip to content

Commit ac7a067

Browse files
authored
Merge pull request #46 from firstlookmedia/entry-config
adds 'clientEntry' and 'serverEntry' as package.json config
2 parents e943a3f + 4289d45 commit ac7a067

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

config/packageConfig.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('path');
2+
3+
const packageConfig = require(path.resolve('package.json'));
4+
5+
const reactScriptPackageConfig = {
6+
...packageConfig['react-scripts'],
7+
};
8+
9+
module.exports = reactScriptPackageConfig;

config/webpack.defaults.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require('path');
22
const autoprefixer = require('autoprefixer');
33
const precss = require('precss');
44
const postcssCalc = require('postcss-calc');
5+
const packageConfig = require('./packageConfig');
56

67
const cssOptions = {
78
sourceMap: true,
@@ -20,7 +21,10 @@ const babelOptions = {
2021
module.exports = {
2122
mode: 'development',
2223
context: __dirname,
23-
entry: ['babel-polyfill', path.resolve('src/index.js')],
24+
entry: [
25+
'babel-polyfill',
26+
path.resolve(packageConfig.clientEntry || 'src/index.js'),
27+
],
2428
output: {
2529
filename: '[name].js',
2630
path: path.resolve('build/assets'),

config/webpack.server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const nodeExternals = require('webpack-node-externals');
44
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
55
const merge = require('webpack-merge');
66
const defaults = require('./webpack.defaults.js');
7+
const packageConfig = require('./packageConfig');
78

89
module.exports = merge.smart({
910
module: {
@@ -26,7 +27,7 @@ module.exports = merge.smart({
2627
__dirname: false,
2728
setImmediate: false,
2829
},
29-
entry: path.resolve('server.js'),
30+
entry: path.resolve(packageConfig.serverEntry || 'server.js'),
3031
output: {
3132
filename: 'server.js',
3233
path: path.resolve('build'),

scripts/utils/relayCompilerArguments.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
const path = require('path');
2-
3-
const packageConfig = require(path.resolve('package.json'));
2+
const packageConfig = require('../../config/packageConfig.js');
43

54
// relay compiler
65

76
let includePaths = ['src/**'];
87
const excludePaths = ['**/__generated__/**'];
9-
if ('react-scripts' in packageConfig) {
10-
const moduleName = packageConfig['react-scripts'].sharedComponentModule;
11-
if (moduleName) {
12-
includePaths = includePaths.concat(`node_modules/${moduleName}/src/**`);
13-
}
8+
const moduleName = packageConfig.sharedComponentModule;
9+
if (moduleName) {
10+
includePaths = includePaths.concat(`node_modules/${moduleName}/src/**`);
1411
}
1512
const extensions = ['js', 'jsx', 'ts', 'tsx'];
1613

0 commit comments

Comments
 (0)