diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 41d5e62..b36d7eb 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -2,6 +2,7 @@ const path = require('path'); const webpack = require('webpack'); +const {execSync} = require('child_process'); const PnpWebpackPlugin = require('pnp-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); @@ -14,6 +15,7 @@ const paths = require('./paths'); const ManifestPlugin = require('webpack-manifest-plugin'); const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); +const gitHash = execSync('git rev-parse --short HEAD').toString().trim(); // Webpack uses `publicPath` to determine where the app is being served from. // In development, we always serve from the root. This makes config easier. @@ -177,7 +179,7 @@ module.exports = { options: { formatter: require.resolve('react-dev-utils/eslintFormatter'), eslintPath: require.resolve('eslint'), - + }, loader: require.resolve('eslint-loader'), }, @@ -210,7 +212,7 @@ module.exports = { customize: require.resolve( 'babel-preset-react-app/webpack-overrides' ), - + plugins: [ [ require.resolve('babel-plugin-named-asset-import'), @@ -250,7 +252,7 @@ module.exports = { cacheDirectory: true, // Don't waste time on Gzipping the cache cacheCompression: false, - + // If an error happens in a package, it's possible to be // because it was compiled. Thus, we don't want the browser // debugger to show the original code. Instead, the code @@ -327,6 +329,11 @@ module.exports = { ], }, plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + 'GIT_HASH': JSON.stringify(gitHash) + } + }), // Generates an `index.html` file with the