Skip to content

Commit 4eb8eb7

Browse files
committed
Use HtmlWebpackPlugin cache busting
1 parent 5806e17 commit 4eb8eb7

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,11 @@ module.exports = function(webpackEnv) {
210210
pathinfo: isEnvDevelopment,
211211
// There will be one main bundle, and one file per asynchronous chunk.
212212
// In development, it does not produce real files.
213-
filename: isEnvProduction
214-
? 'static/js/[name].[contenthash:8].js'
215-
: isEnvDevelopment && 'static/js/[name].[contenthash:8].js', // wptheme modified... always use cache busting
213+
filename: 'static/js/bundle.js', // wptheme modified... always use cache busting via the HtmlWebpackPlugin config, way below here
216214
// TODO: remove this when upgrading to webpack 5
217215
futureEmitAssets: true,
218216
// There are also additional JS chunk files if you use code splitting.
219-
chunkFilename: isEnvProduction
220-
? 'static/js/[name].[contenthash:8].chunk.js'
221-
: isEnvDevelopment && 'static/js/[name].[contenthash:8].chunk.js', // wptheme modified... always use cache busting
217+
chunkFilename: 'static/js/[name].chunk.js', // wptheme modified... always use cache busting via the HtmlWebpackPlugin config, way below here
222218
// We inferred the "public path" (such as / or /my-project) from homepage.
223219
// We use "/" in development.
224220
publicPath: publicPath,
@@ -596,14 +592,14 @@ module.exports = function(webpackEnv) {
596592
},
597593
plugins: [
598594
// Generates an `index.html` file with the <script> injected.
599-
// wptheme -- added php support
600595
new HtmlWebpackPlugin(
601596
Object.assign(
602597
{},
603598
{
604-
filename: 'index.php',
599+
filename: 'index.php', // wptheme -- added php support
605600
inject: true,
606601
template: paths.appHtml,
602+
hash: true, // wptheme modified... always use cache busting
607603
},
608604
isEnvProduction
609605
? {
@@ -665,8 +661,8 @@ module.exports = function(webpackEnv) {
665661
new MiniCssExtractPlugin({
666662
// Options similar to the same options in webpackOptions.output
667663
// both options are optional
668-
filename: 'static/css/[name].[contenthash:8].css',
669-
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
664+
filename: 'static/css/[name].css',
665+
chunkFilename: 'static/css/[name].chunk.css',
670666
}),
671667
// Generate a manifest file which contains a mapping of all asset filenames
672668
// to their corresponding output file so that tools can pick it up without

packages/react-scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devloco/react-scripts-wptheme",
3-
"version": "3.1.1-wptheme-3.1.2",
3+
"version": "3.1.1-wptheme-3.1.3",
44
"description": "Configuration and scripts for Create React WP Theme.",
55
"repository": "devloco/create-react-wptheme",
66
"author": "devloco",

0 commit comments

Comments
 (0)