-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Docz dosent find custom paths #48
Comments
I think that change the Use |
@maxguzenski I got it working by creating a simple plugin, it looks like this: import { createPlugin } from 'docz-core'
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.config')()
/**
* Add support for custom resolvers
*/
const includeResolvers = () =>
createPlugin({
modifyBundlerConfig: (bundler) => {
const merged = merge(bundler, { resolve: baseWebpackConfig.resolve })
return merged
},
})
module.exports = {
source: './src',
plugins: [includeResolvers()],
} I'm still having some odd issues with it, though - some components work, and some don't. Trying to figure out the cause, I'll follow up here or with another issue. |
you can use // doczrc.js
export default {
modifyBundlerConfig: (config) => /* ... */
} |
@pedronauck , I also need to use Also, it might be helpful to throw a warning if there are unexpected or incompatible properties found on config or plugin objects - for instance, if I named my plugin function |
Release v0.2.7 turns possible to pass |
Is there current a way that docz can handle aliases afforded by the |
Hi, same question here... I'm developing a component that should be used inside an mdx file, so I'm adding inside tsconfig.json a path that maps the name of the library to the index of the project, but docz doesn't seem to find it :( |
This works for me: const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
export default {
modifyBundlerConfig: config => {
/*
* use tsconfig paths, e.g.: `import Button from components/Button`
*/
config.resolve.plugins = [
new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })
];
/*
* allow proptype generation with tsconfig.
* https://github.com/pedronauck/docz/issues/240#issuecomment-415689181
*/
const jsxPluginIndex = config.plugins.findIndex(
plugin => plugin.config.id === "jsx"
);
const { loaders } = config.plugins[jsxPluginIndex].config;
const docGenLoaderIndex = loaders.findIndex(loader =>
/react-docgen-typescript-loader/.test(loader.loader)
);
const docGenLoader = loaders[docGenLoaderIndex];
docGenLoader.options = {
tsconfigPath: "./tsconfig.json"
};
return config;
},
typescript: true
}; I still get errors like this at startup:
But those don't seem to actually affect anything. |
@dfee confirmed, I'm getting them as well |
@dfee Is this still working for you? I have tried your config above but i get the following error
|
With the latest version of Docz v2 I was able to utilize TypeScript paths using the following. // gatsby-node.js
const TSPathsPlugin = require('tsconfig-paths-webpack-plugin');
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
plugins: [new TSPathsPlugin({ configFile: '../tsconfig.json' })]
}
});
}; I hope this helps someone who runs into this. I am utilizing it in my NX repo. |
That's work for me. 👍 |
@stramel I tried to make a gatsby-node.js file at the root of my typescript file like what you have there, but this doesn't seem to work for me. My I should be putting the gatsby-node.js file elsewhere. In my tsconfig file, I have these relative imports: "paths": {
"@components/*": ["components/*"],
"@env": ["../env.ts"],
"@pages/*": ["pages/*"],
"@styles/*": ["styles/*"],
"@utilities/*": ["utilities/*"],
}, Does anyone know how to get docz to use these relative imports? |
After a lot of trial and error I got this working similar to @stramel's solution, but also ran into the issue here about the file not being used due to an error. In my case it was a stupid mistake - I was using an To ensure your |
Hi, I have this config on my webpack:
So, in can import without use things like '../'
But on docz, got a error (file not found)
Is there a way to config root paths to find components on docz?
The text was updated successfully, but these errors were encountered: