Docz: onCreateBabelConfig function does not work.

Created on 4 Sep 2019  路  4Comments  路  Source: doczjs/docz

Bug Report

A clear and concise description of what the bug is.
cannot set babel plugin using onCreateBabelConfig function within gatsby-node.js

To Reproduce

create a gatsby-node.js file in the project root folder.

export the function
exports.onCreateBabelConfig = ({ actions }) => { actions.setBabelPlugin({ name: '@babel/plugin-proposal-decorators', options: { legacy: true }, }); };

This setting is ignored,

Expected behavior

This setting should have been used.
In the .docz folder, there is a file called gatsby-node.js which is generated.
but only onCreateWebpackConfig function is described there.
If I directly used the above described onCreateBabelConfig function inside this file and then
built the project, it seems to be working.

Environment

  • OS: [e.g. OSX 10.13.4, Windows 10]
  • Node/npm version: [e.g. Node 12]
question v2

Most helpful comment

you can do it by doczrc.js

just like this:

import { createPlugin } from "docz-core";

const myPlugin = () =>
  createPlugin({
    onCreateBabelConfig({ actions }) {
      actions.setBabelPlugin({
        name: "@babel/plugin-proposal-decorators",
        options: { legacy: true }
      });
    }
  });

export default {
  plugins: [myPlugin()]
};

All 4 comments

you can do it by doczrc.js

just like this:

import { createPlugin } from "docz-core";

const myPlugin = () =>
  createPlugin({
    onCreateBabelConfig({ actions }) {
      actions.setBabelPlugin({
        name: "@babel/plugin-proposal-decorators",
        options: { legacy: true }
      });
    }
  });

export default {
  plugins: [myPlugin()]
};

Tried the above code, could not get it to work. Got the following errror
Screen Shot 2019-09-05 at 09 53 51

Hey @nikitpatel24

@hvsy's code (thanks 馃憦) works for me.

Check out an example with @babel/plugin-proposal-decorators here : https://github.com/doczjs/docz-issue-1031

Indeed it works in the mentioned repo...thanks for your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tadeuszwojcik picture tadeuszwojcik  路  30Comments

tamagokun picture tamagokun  路  23Comments

molebox picture molebox  路  40Comments

robjac picture robjac  路  41Comments

maxguzenski picture maxguzenski  路  24Comments