File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 33 * in order to load fonts and icons, these paths must be reconciled.
44 */
55const fs = require ( 'fs' ) // eslint-disable-line
6+ const path = require ( 'path' ) // eslint-disable-line
67
78// find the generated main css file
89const getMainCSSFile = ( ) => {
910 const regex = / ^ m a i n .[ a - z 0 - 9 ] + .c h u n k .c s s $ /
10- const mainCss = fs . readdirSync ( 'build/static/css' ) . filter ( ( filename ) => filename . match ( regex ) )
11+ const mainCss = fs . readdirSync ( path . resolve ( 'build/static/css' ) ) . filter ( ( filename ) => filename . match ( regex ) )
1112 if ( ! mainCss . length ) {
1213 throw new Error ( 'No main.css file found in build/static/css' )
1314 }
@@ -17,10 +18,10 @@ const getMainCSSFile = () => {
1718// remap the font paths from the borken /fonts/ => ../../fonts/
1819const remapFontPaths = ( ) => {
1920 const mainCSSFile = getMainCSSFile ( )
20- const file = fs . readFileSync ( ` build/static/css/ ${ mainCSSFile } ` , 'utf8' )
21+ const file = fs . readFileSync ( path . join ( ' build/static/css' , mainCSSFile ) , 'utf8' )
2122 const fontUrlRegex = / u r l \( \/ f o n t s \/ / g
2223 const remappedFile = file . replace ( fontUrlRegex , 'url(../../fonts/' )
23- fs . writeFileSync ( ` build/static/css/ ${ mainCSSFile } ` , remappedFile )
24+ fs . writeFileSync ( path . join ( ' build/static/css' , mainCSSFile ) , remappedFile )
2425}
2526
2627remapFontPaths ( )
You can’t perform that action at this time.
0 commit comments