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

Any chance to make it work with CRA? #42

Closed
stereobooster opened this issue Jul 25, 2019 · 4 comments
Closed

Any chance to make it work with CRA? #42

stereobooster opened this issue Jul 25, 2019 · 4 comments

Comments

@stereobooster
Copy link

Hi. Thank you for the project.

This question is asked in every zero-runtime library out there. Can we make it work with CRA out of the box, without need to eject? Can we make use of babel macros for example?

I kind of know the answer already (the problem is inside webpack API) but I keep hoping for the best. This is not an issue more of a discussion.

@montogeek
Copy link

It shouldn't be a problem using any CRA rewired library.

@mattcompiles
Copy link
Contributor

It shouldn't be difficult to integrate treat into CRA. It works in a very similar way to CSS modules and already has an idiomatic file extension (.treat.js|ts). It's mostly just a matter of adding the webpack plugin to your config.

This issue is more one for the CRA maintainers though and whether they want to support treat.

@stereobooster
Copy link
Author

Screenshot 2019-07-27 at 10 34 49

@danielberndt
Copy link

For reference, this is the code that's necessary to use treat in a CRA project via react-app-rewired

// config-overrides.js
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TreatPlugin = require("treat/webpack-plugin");

module.exports = function override(config, env) {
  const isEnvDevelopment = env === "development";
  config.plugins.push(
    new TreatPlugin({
      outputLoaders: [
        isEnvDevelopment ? require.resolve("style-loader") : MiniCssExtractPlugin.loader,
      ],
    })
  );

  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

4 participants