-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
importing tw in a dynamic route throws module not found error for stitches.config.ts #608
Comments
I resorted to following as a workaround in case anyone else comes across this issue. import tw from 'twin.macro'
import { styled } from '@stitches/react'
const Styles = {
PageHeading: styled('h1', {
...tw`font-heading text-3xl font-medium text-gray-800`,
}),
} |
That's a good workaround. // babel-plugin-macros.config.js
module.exports = {
twin: {
stitchesConfig: 'PATH_FROM_PROJECT_ROOT',
},
}
// package.json
"babelMacros": {
"twin": {
"stitchesConfig": "PATH_FROM_PROJECT_ROOT"
}
}, |
Maybe related to #606. I can reproduce it on Windows, but not on macOS. module.exports = {
webpack: (config) => {
config.resolve.preferRelative = true;
return config;
}
} @ben-rogerson let me know if we can help with anything 👍🏼 |
Setting path to "babelMacros": {
"twin": {
"preset": "stitches",
"stitchesConfig": "./stitches.config.ts"
}
} and then setting module.exports = {
webpack: config => {
config.resolve.preferRelative = true
return config
}
} seems to work, now inlining |
Unfortunately, this breaks other imports within the app (at least in my case). I ended up moving From what I saw, it only happens on Windows and has to be something related to how webpack tries to resolve the path to stitches provided by twin.macro. |
I'm getting following error when importing and using
tw
in a dynamic route.Found
preferRelative
in webpack's documentation here. But setting it innext.config.js
did not resolve the issue.The text was updated successfully, but these errors were encountered: