Skip to content
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

How to transpile particular dependency in node modules? #142

Closed
ilyanoskov opened this issue Jul 16, 2018 · 3 comments
Closed

How to transpile particular dependency in node modules? #142

ilyanoskov opened this issue Jul 16, 2018 · 3 comments

Comments

@ilyanoskov
Copy link

ilyanoskov commented Jul 16, 2018

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!

@ilyanoskov
Copy link
Author

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

@good-idea
Copy link
Contributor

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

@ilyanoskov
Copy link
Author

ilyanoskov commented Jul 30, 2018

@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;
  },
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants