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

antd-theme-generator@1.2.3 throws error #42

Closed
afc163 opened this issue May 19, 2020 · 7 comments · Fixed by ant-design/ant-design#24450
Closed

antd-theme-generator@1.2.3 throws error #42

afc163 opened this issue May 19, 2020 · 7 comments · Fixed by ant-design/ant-design#24450

Comments

@afc163
Copy link
Contributor

afc163 commented May 19, 2020

git clone git@github.com:ant-design/ant-design.git
cd ant-design
npm i
npm run color-less

image

> antd@4.2.4 color-less /Users/afc163/Projects/ant-design
> node ./scripts/generate-color-less

🔩 less render start!
error TypeError: Cannot read property 'slice' of undefined
    at generateTheme (/Users/afc163/Projects/ant-design/node_modules/antd-theme-generator/index.js:337:46)
    at Object.<anonymous> (/Users/afc163/Projects/ant-design/scripts/generate-color-less.js:49:1)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11
[LessError: JavaScript evaluation error: 'ReferenceError: colorPalette is not defined'] {
  message: "JavaScript evaluation error: 'ReferenceError: colorPalette is not defined'",
  stack: undefined,
  type: 'Syntax',
  filename: '/Users/afc163/Projects/ant-design/node_modules/antd-pro-merge-less/.temp/pro.less',
  index: 561955,
  line: 26146,
  column: 0,
  callLine: NaN,
  callExtract: undefined,
  extract: [
    '// ========================== Tree ==========================',
    '.antTreeFn(@select-tree-prefix-cls);',
    ''
  ]
}

1.2.2 works fine.

github-actions bot pushed a commit to ant-design/ant-design that referenced this issue May 19, 2020
afc163 added a commit to ant-design/ant-design that referenced this issue May 19, 2020
afc163 added a commit to ant-design/ant-design that referenced this issue May 19, 2020
* chore(list): improve code (#24280)

* chore(list): improve code

* Update index.tsx

* refactor: tree select style code

* 🔒 lock antd-theme-generator to 1.2.2

mzohaibqc/antd-theme-generator#42

Co-authored-by: Tom Xu <ycxzhkx@gmail.com>
@mzohaibqc
Copy link
Owner

mzohaibqc commented May 19, 2020

@afc163 I ran it locally and was able to reproduce it. There is missing parameter antDir: path.join(__dirname, '../node_modules/antd') in options which I added

const options = {
  antDir: path.join(__dirname, '../node_modules/antd'),
  stylesDir: path.join(__dirname, '../site/theme/static'),
  antdStylesDir: path.join(__dirname, '../components'),
  varFile: path.join(__dirname, '../components/style/themes/default.less'),
  mainLessFile: path.join(__dirname, '../site/theme/static/index.less'),
  themeVariables: ['@primary-color'],
  outputFilePath: path.join(__dirname, '../_site/color.less'),
};

generateTheme(options);

But now I am getting for antd-pro-merge-less since some files are using some less variables which are not imported e.g.

image

@chenshuai2144 You might need to look into this since antd-pro-merge-less is developed by you and you know how it works.

@afc163 Keep me updated and if there is some change required in antd-theme-generator, let me know

@afc163
Copy link
Contributor Author

afc163 commented May 19, 2020

No errors(antd-theme-generator or antd-pro-merge-less) throw when using antd-theme-generator@1.2.2 even without antDir. Is V2 being released as 1.2.3 unexpectedly?

@mzohaibqc
Copy link
Owner

@afc163 antDir parameter was always there since 1st version as you can see here

https://www.npmjs.com/package/antd-theme-generator/v/1.0.0

You are right that is was working before v1.2.3 without antDir but in order to fix some bugs, it is required now.

But even you comment generateTheme(options); line, it is still breaking as I added a screenshot above . antd-pro-merge-less is breaking since there is no variables imported referenced in that file e.g. @site-text-color is not imported here https://github.com/ant-design/ant-design/blob/master/site/theme/static/demo.less

@chenshuai2144 Can tell, how antd-pro-merge-less works

image

mzohaibqc added a commit that referenced this issue May 19, 2020
@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented May 20, 2020

antd-pro-merge-less will create file in _site folder.
you can create _site folder, will fix this error

@afc163
Copy link
Contributor Author

afc163 commented May 24, 2020

Problem still exists in ant-design/ant-design#24324, antd-pro-merge-less has fixed it's problem.

@mzohaibqc
Copy link
Owner

@afc163 Kindly have a look at this PR and merge it if looks good to you.

ant-design/ant-design#24450

@mzohaibqc
Copy link
Owner

@afc163 Kindly have a look at this PR and merge it if looks good to you.

ant-design/ant-design#24450

Thanks, @afc163 for merging this PR. Let me know if you find some primary color not being updated on selecting different primary color from footer primary color selector.

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

Successfully merging a pull request may close this issue.

3 participants