File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
packages/gatsby/src/utils Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,21 @@ export function generateComponentChunkName(componentPath: string): string {
4646 } else {
4747 const { program } = store . getState ( )
4848 const directory = program ?. directory || `/`
49- const name = pathRelative ( directory , componentPath )
49+ let name = pathRelative ( directory , componentPath )
5050
51- const chunkName = `component---${ replaceUnifiedRoutesKeys (
51+ const prefix = `component---`
52+ const maxLength = 255 - directory . length - prefix . length
53+
54+ // Shorten path name to not exceed max length of 255 characters
55+ if ( name . length > maxLength ) {
56+ const hash = require ( `crypto` )
57+ . createHash ( `sha1` )
58+ . update ( name )
59+ . digest ( `base64` )
60+ name = `${ name . substring ( 0 , maxLength - 41 ) } -${ hash } `
61+ }
62+
63+ const chunkName = `${ prefix } ${ replaceUnifiedRoutesKeys (
5264 kebabCase ( name ) ,
5365 name
5466 ) } `
You can’t perform that action at this time.
0 commit comments