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 extend default webpack configuration? #194

Closed
Jmlevick opened this issue Nov 16, 2017 · 2 comments
Closed

How to extend default webpack configuration? #194

Jmlevick opened this issue Nov 16, 2017 · 2 comments

Comments

@Jmlevick
Copy link

Jmlevick commented Nov 16, 2017

So, I've just found out about this project and it seems pretty interesting. However, also recently I found out about https://tailwindcss.com/ and I was wondering about how can I mix the two together? I mean, while reading about #162 I discovered a method of doing a little bit of handling on the webpack configuration and I was wondering if maybe the installation steps for tailwind on webpack could be applicable for a roc project (I think so!); I've read:

https://tailwindcss.com/docs/installation

and checked out the code on:

https://github.com/tailwindcss/webpack-starter

and so far what I have is something like the following:

https://gist.github.com/Jmlevick/2a52d491877b40afa776d5b86254d4b3

But it fails with:

TypeError: arguments[i].apply is not a function

I've tried with other approaches to no avail, any ideas?

@Jmlevick
Copy link
Author

Solved this particular issue with a gulp task. Maybe not the best way to do it but it works for me, code below:

https://gist.github.com/Jmlevick/419c772e69d25ac720a62af60ed3b12e

@dlmr
Copy link
Member

dlmr commented Nov 18, 2017

Hi, sorry for not answering sooner!

Looks like the problem you had was because you converted the Webpack config to JSON when it needs to be JavaScript; const currentConf = JSON.parse(JSON.stringify(webpackConfig));.

project: {
    actions: [{
      hook: 'build-webpack',
      action: () => () => (webpackConfig) => {
        webpackConfig.plugins.push(tailwindcss('./tailwind.js'));
        return webpackConfig;
      },
    }],
  },

This might work.

You can also modify the Webpack configuration under the webpack property where it will be automatically merged with the existing configuration.

// roc.config.js
module.exports = {

    webpack: () => {
        const tailwindcss = require('tailwindcss');
        return {
            plugins: [
                tailwindcss('./path/to/your/tailwind-config.js'),
            ],
        };
    }
};

Great hat you found a solution that works for you!

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