Skip to content

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

@j-a-h-i-r

Description

@j-a-h-i-r

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions