New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.38.0 breaks custom Webpack loader #78
Comments
This is a bug in Next.js 11: vercel/next.js#26130 They've already fixed it so it'll be available in the next patch release. The above issue has a workaround. So I'm going to go ahead and close this since there's nothing actionable for us |
Cool, thanks for letting me know! |
I'm still having this issue on the latest version of blitz. |
@gielcobben For me the problem (with SVGR) is completely resolved. Maybe an other issue? Maybe you could post your SVGR setup and how you load the files. |
Thanks for the reply. Would you mind sharing your config? Here is mine:
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
})
return config
},
declare module "*.svg" {
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
export default ReactComponent
} |
@gielcobben Sure, below are mine (but yours look ok). What's the output of
declare module "*.svg" {
import { VFC, SVGProps } from "react"
const SVG: VFC<SVGProps<SVGSVGElement>>
export default SVG
}
import { sessionMiddleware, simpleRolesIsAuthorized } from "blitz"
import bundleAnalyzer from "@next/bundle-analyzer"
const enableBundleAnalyzer = process.env.npm_lifecycle_event === "build"
const withBundleAnalyzer = bundleAnalyzer({
enabled: enableBundleAnalyzer,
})
module.exports = withBundleAnalyzer({
middleware: [
sessionMiddleware({
cookiePrefix: "foobar",
isAuthorized: simpleRolesIsAuthorized,
}),
],
i18n: {
localeDetection: false,
locales: ["en", "de", "cimode"],
defaultLocale: "en",
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Allows the modules to find their module name during build time
config.node = {
...config.node,
__dirname: true,
}
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [
{
cleanupIDs: false,
prefixIds: false,
convertPathData: false,
},
],
},
},
},
],
})
return config
},
})
let icons: object
if (process.env.NODE_ENV !== "test") {
const iconsContext = require.context("./", true, /\.svg$/)
icons = iconsContext.keys().reduce((icons, file) => {
const Icon = iconsContext(file).default
const label = file.slice(2, -4) // strip './' and '.svg'
icons[label] = Icon
return icons
}, {})
} else {
// We have to mock require.context for Jest as it is Webpack only
icons = {}
}
export default icons |
Should be fixed on |
What is the problem?
I use SVGR as a Webpack plugin to load SVGs as React components. This worked fine till Blitz 0.37.0. But Blitz 0.38.x seems to break things. The SVGs can't be loaded anymore (
TypeError: unsupported file type: undefined (file: undefined)
).Note: The problem occurs with Webpack 4 and 5.
Paste all your error logs here:
Paste all relevant code snippets here:
blitz.config.ts
How I load my SVGs
Note:
I also tried it without
require.context
and just useimport
syntax, but it results in the same error.What are detailed steps to reproduce this?
I created a new Blitz project to demonstrate the problem, https://github.com/medihack/blitz_v0.38.1
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
No response
The text was updated successfully, but these errors were encountered: