File tree 4 files changed +29
-12
lines changed
4 files changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -352,13 +352,14 @@ module.exports = async (args: BootstrapArgs) => {
352
352
)
353
353
354
354
const browserPluginsRequires = browserPlugins
355
- . map (
356
- plugin =>
357
- `{
358
- plugin: require('${ plugin . resolve } '),
355
+ . map ( plugin => {
356
+ // we need a relative import path to keep contenthash the same if directory changes
357
+ const relativePluginPath = path . relative ( siteDir , plugin . resolve )
358
+ return `{
359
+ plugin: require('${ slash ( relativePluginPath ) } '),
359
360
options: ${ JSON . stringify ( plugin . options ) } ,
360
361
}`
361
- )
362
+ } )
362
363
. join ( `,` )
363
364
364
365
const browserAPIRunner = `module.exports = [${ browserPluginsRequires } ]\n`
Original file line number Diff line number Diff line change 1
1
const _ = require ( `lodash` )
2
+ const path = require ( `path` )
2
3
const fs = require ( `fs-extra` )
3
4
const crypto = require ( `crypto` )
5
+ const slash = require ( `slash` )
4
6
const { store, emitter } = require ( `../redux/` )
5
7
const reporter = require ( `gatsby-cli/lib/reporter` )
6
8
const { match } = require ( `@reach/router/lib/utils` )
@@ -143,12 +145,17 @@ const preferDefault = m => m && m.default || m
143
145
const preferDefault = m => m && m.default || m
144
146
\n`
145
147
asyncRequires += `exports.components = {\n${ components
146
- . map (
147
- c =>
148
- ` "${ c . componentChunkName } ": () => import("${ joinPath (
149
- c . component
150
- ) } " /* webpackChunkName: "${ c . componentChunkName } " */)`
151
- )
148
+ . map ( c => {
149
+ // we need a relative import path to keep contenthash the same if directory changes
150
+ const relativeComponentPath = path . relative (
151
+ path . join ( program . directory , `.cache` ) ,
152
+ c . component
153
+ )
154
+
155
+ return ` "${ c . componentChunkName } ": () => import("${ slash (
156
+ relativeComponentPath
157
+ ) } " /* webpackChunkName: "${ c . componentChunkName } " */)`
158
+ } )
152
159
. join ( `,\n` ) }
153
160
}\n\n`
154
161
Original file line number Diff line number Diff line change @@ -459,7 +459,10 @@ module.exports = async ({
459
459
loaders . css ( { ...options , importLoaders : 1 } ) ,
460
460
loaders . postcss ( { browsers } ) ,
461
461
]
462
- if ( ! isSSR ) use . unshift ( loaders . miniCssExtract ( { hmr : ! options . modules } ) )
462
+ if ( ! isSSR )
463
+ use . unshift (
464
+ loaders . miniCssExtract ( { hmr : ! PRODUCTION && ! options . modules } )
465
+ )
463
466
464
467
return {
465
468
use,
Original file line number Diff line number Diff line change @@ -469,6 +469,10 @@ module.exports = async (
469
469
runtimeChunk : {
470
470
name : `webpack-runtime` ,
471
471
} ,
472
+ // use hashes instead of ids for module identifiers
473
+ // TODO update to deterministic in webpack 5 (hashed is deprecated)
474
+ // @see https://webpack.js.org/guides/caching/#module-identifiers
475
+ moduleIds : `hashed` ,
472
476
splitChunks : {
473
477
name : false ,
474
478
chunks : `all` ,
@@ -497,6 +501,8 @@ module.exports = async (
497
501
test : / \. ( c s s | s c s s | s a s s | l e s s | s t y l ) $ / ,
498
502
chunks : `all` ,
499
503
enforce : true ,
504
+ // this rule trumps all other rules because of the priority.
505
+ priority : 10 ,
500
506
} ,
501
507
} ,
502
508
} ,
You can’t perform that action at this time.
0 commit comments