Skip to content

Commit 29913e5

Browse files
author
Ives van Hoorne
committed
Move version logic to production
1 parent 69ee11b commit 29913e5

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

config/webpack.common.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
55
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
66
const CopyWebpackPlugin = require('copy-webpack-plugin');
77
const HappyPack = require('happypack');
8-
const childProcess = require('child_process');
98
const WatchMissingNodeModulesPlugin = require('../scripts/utils/WatchMissingNodeModulesPlugin');
109
const env = require('./env');
1110

@@ -17,15 +16,6 @@ const __DEV__ = NODE_ENV === 'development'; // eslint-disable-line no-underscore
1716
const __PROD__ = NODE_ENV === 'production'; // eslint-disable-line no-underscore-dangle
1817
const babelConfig = __DEV__ ? babelDev : babelProd;
1918

20-
const COMMIT_COUNT = childProcess
21-
.execSync('git rev-list --count HEAD')
22-
.toString();
23-
24-
const COMMIT_HASH = childProcess
25-
.execSync('git rev-parse --short HEAD')
26-
.toString();
27-
const VERSION = `${COMMIT_COUNT}-${COMMIT_HASH}`;
28-
2919
module.exports = {
3020
entry: {
3121
app: [require.resolve('./polyfills'), path.join(paths.appSrc, 'index.js')],
@@ -206,7 +196,6 @@ module.exports = {
206196
// Makes some environment variables available to the JS code, for example:
207197
// if (process.env.NODE_ENV === 'development') { ... }. See `env.js`.
208198
new webpack.DefinePlugin(env),
209-
new webpack.DefinePlugin({ VERSION: JSON.stringify(VERSION) }),
210199
// Watcher doesn't work well if you mistype casing in a path so we use
211200
// a plugin that prints an error when you attempt to do this.
212201
// See https://github.com/facebookincubator/create-react-app/issues/240

config/webpack.prod.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
const merge = require('webpack-merge');
22
const webpack = require('webpack');
33
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
4+
const childProcess = require('child_process');
45
const commonConfig = require('./webpack.common');
56

67
const publicPath = '/';
78

9+
const COMMIT_COUNT = childProcess
10+
.execSync('git rev-list --count HEAD')
11+
.toString();
12+
13+
const COMMIT_HASH = childProcess
14+
.execSync('git rev-parse --short HEAD')
15+
.toString();
16+
const VERSION = `${COMMIT_COUNT}-${COMMIT_HASH}`;
17+
818
module.exports = merge(commonConfig, {
919
devtool: 'source-map',
1020
output: {
@@ -13,6 +23,7 @@ module.exports = merge(commonConfig, {
1323
sourceMapFilename: '[file].map', // Default
1424
},
1525
plugins: [
26+
new webpack.DefinePlugin({ VERSION: JSON.stringify(VERSION) }),
1627
new webpack.LoaderOptionsPlugin({
1728
minimize: true,
1829
debug: false,

0 commit comments

Comments
 (0)