Code Monkey home page Code Monkey logo

antd_less_v6_bug's Introduction

This is a demo repo to reproduce the less loader issue

./node_modules/antd/es/button/style/index.less (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-7-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js??ref--6-oneOf-7-3!./node_modules/antd/es/button/style/index.less)
ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'source'. These properties are valid:
   object { lessOptions?, prependData?, appendData?, sourceMap? }

Workaround

$ yarn remove less-loader

// less-loader v6.0.0 is not working
$ yarn add [email protected]

Reproduce Step

create repo by create-react-app

packages may need to install: babel-plugin-import customize-cra less-loader react-app-rewired

const { override, fixBabelImports, addLessLoader } = require('customize-cra')

module.exports = override(
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true,
  }),
  addLessLoader({
    lessOptions: {
      javascriptEnabled: true,
      // See all variables here:
      // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
      modifyVars: {
        '@layout-header-background': '#0D223D',

      }
    },
  })
)

Add a <Button> from antd to your App.js and start server

possible reason

Caused by customize-cra package

https://github.com/arackaf/customize-cra/blob/404854bcbe7436f5834e4c4863001610951d5c3c/src/customizers/webpack.js#L167-L169

related issue

arackaf/customize-cra#241 ant-design/ant-design#23624

antd_less_v6_bug's People

Contributors

dependabot[bot] avatar nothingrealhappen avatar

Watchers

 avatar  avatar  avatar

antd_less_v6_bug's Issues

Workaround doesn't work

Thank you for your workaround - I tried to use it but get another error.

  1. git clone https://github.com/ant-design/create-react-app-antd
  2. yarn
  3. yarn remove less-loader
  4. yarn add [email protected]
  5. yarn start
  6. Got error:
Failed to compile.

./node_modules/antd/es/date-picker/style/index.less (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-7-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js??ref--6-oneOf-7-3!./node_modules/antd/es/date-picker/style/index.less)

// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?
      in /app/node_modules/antd/es/style/color/bezierEasing.less (line 110, column 0)

I use the following Dockerfile:

FROM node

WORKDIR /app/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.