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

Does it not work with custom value for NODE_ENV? #72

Open
j-a-h-i-r opened this issue Jun 29, 2021 · 0 comments
Open

Does it not work with custom value for NODE_ENV? #72

j-a-h-i-r opened this issue Jun 29, 2021 · 0 comments

Comments

@j-a-h-i-r
Copy link

My NODE_ENV is set to custom. I'm trying to set up ant design in a CRA project. I'm following the guide here, https://ant.design/docs/react/use-with-create-react-app. I created a craco.config.js file like the following,

const CracoLessPlugin = require('craco-less');

module.exports = {
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            modifyVars: {
              '@primary-color': '#1DA57A'
            },
            javascriptEnabled: true,
          },
        },
      },
    },
  ],
};

But upon npm start (craco start), I am greeted with the following error,

(node:16620) UnhandledPromiseRejectionWarning: Error: Found an unhandled loader in the custom webpack config: E:\project\node_modules\style-loader\dist\cjs.js

I looked at the source and it seems to be checking the environment variable,

if (
      (context.env === "development" || context.env === "test") &&
      rule.loader.includes(`${pathSep}style-loader${pathSep}`)
    ) {
      lessRule.use.push({
        loader: rule.loader,
        options: {
          ...rule.options,
          ...(pluginOptions.styleLoaderOptions || {}),
        },
      });
    }

After I set my NODE_ENV to development this error is gone.

I am not exactly sure what caused the issue. So my question is does craco-less not support setting a custom value to NODE_ENV?

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

1 participant