Please reference to following code, the first param of onCreateWebpackConfig hook is an immutable object.
I'm sorry I'm not sure I understand the issue.
Are you looking to modify docz's webpack config in a project ?
I'm experiencing the same issue.
At the root of my project i've added a custom gatsby-node.js file:
const path = require('path');
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
alias: {
theme: path.resolve(__dirname, '../src/lib/theme'),
},
},
});
};
However, when I run yarn docz:dev my components are not able to resolve theme.
I've tried several variations of this command, with no success. Either I'm doing something wrong or docz just isn't able to resolve this configuration.
Was going to come here to report this, but then spotted this issue, so it looks like indeed there's a bug.
Help appreciated, thanks!
Thanks @josebrito for clearing that up.
Looking into it :+1:
Is the project a Gatsby app ?
@rakannimer in my case, no. Docz is the only package dependent on Gatsby.
Should be fixed in 2.0.0-rc.28
Please give it a try and let me know
@rakannimer
I try to rewrite the less plugin for v2 and then meet this problem.
In the v1, the first parameter of "modifyBundlerConfig" is an object of "webpack-chain".
however, the parameter of v2 is an independent object. you can't add new module rule for webpack by modify the parameter.
following code from v2.
https://github.com/doczjs/docz/blob/2f29e1d4a18854bd32618960c97a697df13a85d7/core/gatsby-theme-docz/lib/onCreateWebpackConfig.js#L13
Hey @hvsy
You're right you can't modify the config object directly, to modify the webpack config you can use actions.setWebpackConfig
Example :
exports.onCreateWebpackConfig = ({
stage, getConfig, rules, loaders, actions
}) => {
actions.setWebpackConfig({
module: {
rules: [
{
test: 'my-css',
use: [loaders.style(), loaders.css()]
},
],
},
});
}
More info can be found here : https://www.docz.site/docs/creating-plugins
Does that address your issue ? Or am I missing something ?
@rakannimer
please check following code
https://github.com/doczjs/docz/blob/2f29e1d4a18854bd32618960c97a697df13a85d7/core/gatsby-theme-docz/lib/onCreateWebpackConfig.js#L31
the first parameter is not "actions" but "config"
Ok understood 馃槄!
I will add an argument to avoid breaking v2 plugins replace config with params to match the documentation.
No need to add additional argument.
because the current "config" object is immutable. existing v2 plugins hasn't a working.
Changed https://github.com/doczjs/docz/pull/1072/commits/66546a4e2ec2bb90847e137f8159b1784c26f04d in 2.0.0-rc.32
Also onCreateBabelConfig does not seem to work.
exports.onCreateBabelConfig = ({ actions }) => {
actions.setBabelPlugin({
name: '@babel/plugin-proposal-decorators',
options: {
legacy: true
},
});
};
@hvsy, yep replaced actions with params now to match docs.
@nikitpatel24 this looks like a separate problem, params are passed down correctly for onCreateBabelConfig. Could you open another issue to pin down your problem ?
Hi, sorry for the lack of updates, just wanted to confirm that issue is fixed. Thanks!
Most helpful comment
@hvsy, yep replaced actions with params now to match docs.
@nikitpatel24 this looks like a separate problem, params are passed down correctly for onCreateBabelConfig. Could you open another issue to pin down your problem ?