Skip to content

Commit facec88

Browse files
committed
Use env var BUILD_ID
1 parent 24952cf commit facec88

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/react-scripts/config/webpack.config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
3838
// @remove-on-eject-end
3939
const postcssNormalize = require('postcss-normalize');
4040

41-
const commit = require('child_process').execSync('git rev-parse --verify HEAD').toString().trim();
41+
const BUILD_ID = process.env.BUILD_ID || '';
4242

4343
const appPackageJson = require(paths.appPackageJson);
4444

@@ -186,14 +186,14 @@ module.exports = function(webpackEnv) {
186186
// There will be one main bundle, and one file per asynchronous chunk.
187187
// In development, it does not produce real files.
188188
filename: isEnvProduction
189-
? `static${commit}/js/[name].[contenthash:8].js`
190-
: isEnvDevelopment && `static${commit}/js/bundle.js`,
189+
? `static-${BUILD_ID}/js/[name].[contenthash:8].js`
190+
: isEnvDevelopment && `static-${BUILD_ID}/js/bundle.js`,
191191
// TODO: remove this when upgrading to webpack 5
192192
futureEmitAssets: true,
193193
// There are also additional JS chunk files if you use code splitting.
194194
chunkFilename: isEnvProduction
195-
? `static${commit}/js/[name].[contenthash:8].chunk.js`
196-
: isEnvDevelopment && `static${commit}/js/[name].chunk.js`,
195+
? `static-${BUILD_ID}/js/[name].[contenthash:8].chunk.js`
196+
: isEnvDevelopment && `static-${BUILD_ID}/js/[name].chunk.js`,
197197
// We inferred the "public path" (such as / or /my-project) from homepage.
198198
// We use "/" in development.
199199
publicPath: publicPath,
@@ -398,7 +398,7 @@ module.exports = function(webpackEnv) {
398398
loader: require.resolve('url-loader'),
399399
options: {
400400
limit: imageInlineSizeLimit,
401-
name: `static${commit}/media/[name].[hash:8].[ext]`,
401+
name: `static-${BUILD_ID}/media/[name].[hash:8].[ext]`,
402402
},
403403
},
404404
// Process application JS with Babel.
@@ -572,7 +572,7 @@ module.exports = function(webpackEnv) {
572572
// by webpacks internal loaders.
573573
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
574574
options: {
575-
name: `static${commit}/media/[name].[hash:8].[ext]`,
575+
name: `static-${BUILD_ID}/media/[name].[hash:8].[ext]`,
576576
},
577577
},
578578
// ** STOP ** Are you adding a new loader?
@@ -646,8 +646,8 @@ module.exports = function(webpackEnv) {
646646
new MiniCssExtractPlugin({
647647
// Options similar to the same options in webpackOptions.output
648648
// both options are optional
649-
filename: `static${commit}/css/[name].[contenthash:8].css`,
650-
chunkFilename: `static${commit}/css/[name].[contenthash:8].chunk.css`,
649+
filename: `static-${BUILD_ID}/css/[name].[contenthash:8].css`,
650+
chunkFilename: `static-${BUILD_ID}/css/[name].[contenthash:8].chunk.css`,
651651
}),
652652
// Generate an asset manifest file with the following content:
653653
// - "files" key: Mapping of all asset filenames to their corresponding

0 commit comments

Comments
 (0)