Docz: How to transpile particular dependency in node modules?

Created on 16 Jul 2018  路  3Comments  路  Source: doczjs/docz

Question

Description

How do I add an exception for a webpack loader? I need to transpile one dependency, and I know that node_modules folder gets excluded from transpiling. I have a dependency that I install from GitHub. I don't know how to set this up correctly with docz, and wondered in which direction should I look.

my doczrc.js file looks like this:

export default {
  modifyBundlerConfig: config => {
    const newConfig = config;
    newConfig.module
      .rule('js')
      .test(/\.(js|jsx|mjs)$/)
      .include.add(/node_modules\/circuit-ui/)
      .end();

    return newConfig;
  },
};

but obviously it does not work. Do you have any suggestions ?

P.S. thank you for such a great project!

Most helpful comment

@good-idea , this is how I ended up doing it. I manually found the particular jsRule through console.logs and added an exclusion. Let me know if this helps :)

my doczrc.js :

import { babel } from 'docz-plugin-babel6';

export default {
  plugins: [babel()],
  modifyBundlerConfig: config => {
    const jsRule = config.module.rules.find(rule => rule.test.test('*.js'));
    jsRule.exclude = [/node_modules(?!\/circuit-ui)/];

    return config;
  },
};

All 3 comments

I have resolved the issue, will share my solution later.

@ilyanoskov , I'm having a similar issue, could you share what you came up with?

@good-idea , this is how I ended up doing it. I manually found the particular jsRule through console.logs and added an exclusion. Let me know if this helps :)

my doczrc.js :

import { babel } from 'docz-plugin-babel6';

export default {
  plugins: [babel()],
  modifyBundlerConfig: config => {
    const jsRule = config.module.rules.find(rule => rule.test.test('*.js'));
    jsRule.exclude = [/node_modules(?!\/circuit-ui)/];

    return config;
  },
};

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mquandalle picture mquandalle  路  3Comments

meetromb picture meetromb  路  3Comments

regrettably picture regrettably  路  3Comments

bichotll picture bichotll  路  3Comments

hayk94 picture hayk94  路  3Comments