Using Sage 9.0.10, I get this error when running yarn build with a font in the fonts directory.
Any ideas why this might be happening?
error in ./resources/assets/styles/main.scss
Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve './fonts/Objectivity-Regular.woff2' in '/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/resources/assets/styles'
at factoryCallback (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/webpack/lib/Compilation.js:276:40)
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/webpack/lib/NormalModuleFactory.js:235:20
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/webpack/lib/NormalModuleFactory.js:60:20
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/webpack/lib/NormalModuleFactory.js:127:20
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/async/dist/async.js:3888:9
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/async/dist/async.js:473:16
at iteratorCallback (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/async/dist/async.js:1062:13)
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/async/dist/async.js:969:16
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/async/dist/async.js:3885:13
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/webpack/lib/NormalModuleFactory.js:119:22
at onError (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/Resolver.js:65:10)
at loggingCallbackWrapper (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at runAfter (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/Resolver.js:158:4)
at innerCallback (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/Resolver.js:146:3)
at loggingCallbackWrapper (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/tapable/lib/Tapable.js:252:11)
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:40:4
at loggingCallbackWrapper (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at runAfter (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/Resolver.js:158:4)
at innerCallback (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/Resolver.js:146:3)
at loggingCallbackWrapper (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/tapable/lib/Tapable.js:252:11)
at innerCallback (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/Resolver.js:144:11)
at loggingCallbackWrapper (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/tapable/lib/Tapable.js:249:35)
at /Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:44:6
at loggingCallbackWrapper (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at afterInnerCallback (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/Resolver.js:168:10)
at loggingCallbackWrapper (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/node_modules/tapable/lib/Tapable.js:252:11)
In /resources/assets/styles/common/_fonts.scss (This file is imported into main.scss)
I forgot where I saw it, but an answer on a pull request was to downgrade the modules back to: "resolve-url-loader": "~2.3.1" and "file-loader": "^1.1.6"
This works now, however, that might trigger some other domino effect.
Should I upgrade or downgrade Sage?
Which composer create-project function should be run for Sage 9.1?
After running, composer create-project roots/sage your-theme-name dev-master, there’s no Sage version listed in package.json. So it’s unclear whether dev version means the v9.x or v10.x branch.
No files matching the pattern "/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/resources/assets/**/*.(s(c|a)ss|css)" were found.
Even though, I have clearly stated in my .stylelintignore file (which had worked in Sage 9.0.9 projects): resources/assets/styles/**/*.scss
You can see the error is does not include the styles directory. Is my pattern or path wrong?
Whenever I run yarn start or build, I get the error. My paths in my .stylelintignore have always been the same from Sage project to project, since Sage 9.0.3 - 9.0.9.
Why would it stop matching the same exact path now?
This didn’t start happening until Sage 9.0.10.
The webpack.config.js files and package.json rules are the same wherever stylelint is specified.
The only things that are different are the stylelint-related module versions.
Again, in the error, there is no styles directory being returned after the assets directory, yet that’s how it’s defined on line 33 in package.json:
The error: No files matching the pattern "/Volumes/Evo/Local Sites/gateway/app/public/wp-content/themes/sage-gateway/resources/assets/**/*.(s(c|a)ss|css)" were found.
This is confusing me as well. I don’t see any errors when I run yarn build or yarn start. However, no fonts from the resources/assets/fonts folder get pulled into dist. So, then the browser shows warnings that say: Failed to decode downloaded font and OTS parsing error invalid sfntVersion.
I’m guess this has something to do with how the loader is setup?
So I did a test with Sage 9.x release and Sage 9.x update branch and noticed that albeit there is a fonts/ folder in assets/ (using a .gitkeep placeholder), there is webpack config in place to copy it over to dist/....
So this has to be added for Sage 9 themes that need fonts/ in dist/...
See this discussion:
One doesn’t have to use the copy plugin - depending on the workflow and conversion/style needs, one can also use something like postcss-font-magician (this was more important in the past, now all browsers support WOFF/WOFF2).
While that worked for yarn lint:styles it still didn’t work for build or start. It will throw the error as before. In the end I still had comment out the lines in webpack.config.js.
new StyleLintPlugin({
failOnError: !config.enabled.watcher,
syntax: 'scss',
})
No biggie. If I really need to lint some css, I’ll use yarn lint:styles.
Anyway, this is more of a stylelint issue not Sage. Thanks again @strarsis
Hi strarsis - having the same issues with font loading etc - would you be able to point me in the direction of a post describing a safe way to use the 9.x branch? Am quite a way through building out the structure and don’t want to break anything else!
Yeah - just using the Sage 9.x branch. No fonts folder in the distill folder and generates same error. When I remove the fonts from assets and remove font-face declarations all is good. Left the fonts till later so only just seeing this now.`
I ran the build with latest clean update branch version and the font files are 1) copied over to dist/ and 2) I also get no errors, even with non-existing font files in fonts/.