Skip to content

Commit

Permalink
Updated version to 1.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mzohaibqc committed Jun 6, 2020
1 parent 7044561 commit 316a577
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 52 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
This document contains changes in this plugin with each version change.


## [1.3.5] - 2020-05-19 (latest)
## [1.3.6] - 2020-06-06 (latest)
- Fixed following issues
- https://github.com/ant-design/ant-design/issues/24777
- https://github.com/mzohaibqc/antd-theme-generator/issues/45
-
## [1.3.5] - 2020-05-19
- Rewamped base script to remove restriction to use unique theme color values for different variables, now you can use same color for multiple variables or even
variables as value for other variables
- now generated color.less size has been reduced by 30% or more (300kB -> 200kB) due to removal of redundant rules and ant design variables
Expand Down
62 changes: 16 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ const AntDesignThemePlugin = require('antd-theme-webpack-plugin');

const options = {
antDir: path.join(__dirname, './node_modules/antd'),
stylesDir: path.join(__dirname, './src/styles'),
stylesDir: path.join(__dirname, './src'),
varFile: path.join(__dirname, './src/styles/variables.less'),
mainLessFile: path.join(__dirname, './src/styles/index.less'),
themeVariables: ['@primary-color'],
indexFileName: 'index.html',
generateOnce: false,
Expand All @@ -38,37 +37,20 @@ plugins: [
```
Add this plugin in `plugins` array.

- Here are some default paths.
- Default html file name
- index.html
- Ant Design deafult path
- /node_modules/antd
- Default styles directory
- /src/styles
- Default variables file path
- /src/styles/variables.less (import `antd/lib/style/themes/default.less` file at top (important))
- Default styles main file path (not required if you are using verison 1.3.5 or higher)
- /src/styles/index.less
- Default Theme variables (that can be updated in browser)
- ['@primary-color']
- generateOnce: false
- if you don't want to generate color.less on each chnage in code to make build process fast in development mode, assign it `true` value. But if you have new changes in your styles, you need to re-run your build process `npm start`.
- customColorRegexArray: [/^fade\(.*\)$/]
- An array of regex codes to match your custom color variable values so that code can identify that it's a valid color. Make sure your regex does not adds false positives.

So if your directory structure is different or file names are different then provide correct paths as options
while initailizing plugin

If you directory structure is same as below then you don't need to override path
```
/
/src
/styles
/index.less
/variables.less
/otherlessfiles.less
node_modules
public/index.html (index.html file at any path, only name matters in this case)

| Property | Type | Default | Descript |
| --- | --- | --- | --- |
| antdDir | string | - | This is path to antd directory in your node_modules |
| stylesDir | string | - | This is path to your custom styles root directory, all files with .less extension in this folder and nested folders will be processed |
| varFile | string | - | Path to your theme related variables file |
| themeVariables | array | ['@primary-color'] | List of variables that you want to dynamically change |
| indexFileName | string | index.html | File name of your main html file, in most cases it is `index.html` which is default |
| lessUrl | string | https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js | less.js cdn or file path |
| publicPath | string | '' | This string will be appended to `/color.less` in `index.html` file in case |
| generateOnce | boolean | false | Everytime webpack will build new code due to some code changes in development, this plugin will run again unless you specify this flag as `true` which will just compile your styles once |
| customColorRegexArray | array | ['color', 'lighten', 'darken', 'saturate', 'desaturate', 'fadein', 'fadeout', 'fade', 'spin', 'mix', 'hsv', 'tint', 'shade', 'greyscale', 'multiply', 'contrast', 'screen', 'overlay'].map(name => new RegExp(`${name}\(.*\)`))] | This array is to provide regex which will match your color value, most of the time you don't need this |


```
If you `index.html` file is not being generated by build process then add following code in your `index.html` or whatever is the name of html main file and add `indexFileName: false` in options/config. This way you can better place your below script in your html file according to your needs.
Expand Down Expand Up @@ -96,11 +78,6 @@ You need to enable javascript for less-loader.

```
## Below restriction is for verion 1.3.4 or less. Now after v1.3.5, there is no need to use unique hex color codes for your theme variables, you can use same code or even assign a color variable to another theme color.
## Note: (for v1.3.4 or lower version) include all color variables in `varFile` that you want to change dynamically and assign them unique color codes. Don't assign same color to two or more variables and don't use `#fff`, `#ffffff`, `#000` or `#000000`. If you still want white or black color as default, slightly change it e.g. `#fffffe` or `#000001` which will not replace common background colors from other components.

## If you variables have some custom color code like `fade(@primary-color, 20%)` or something that does not matches with common regex to match a valid color then add your custom regex array as `customColorRegexArray` variable in options object while executing `generateTheme(options)`.

For those who are using `react-app-rewire-less` with `react-app-rewired`, enable javascript like this
```
Expand Down Expand Up @@ -129,11 +106,4 @@ https://github.com/mzohaibqc/antd-theme-webpack-plugin/tree/master/examples/cust
Note: you don't necessarily
# Changes

## [1.3.1] - 2020-01-10 (latest)
- Added a custom option, an array of regex to allow your custom color codes to match like `fade(@primary-color, 20%)`

## v1.1.8
- Added support for webpack specific less imports so you can now import like this `@import "~antd/lib/style/themes/default.less";` instead of `@import "../../node_modules/antd/lib/style/themes/default.less";`
- Added cache mechanism to avoid generation of color.less incase of same css/less source.
## [CHANGELOG](/CHNAGELOG.md)
4 changes: 2 additions & 2 deletions examples/customize-cra/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require("path");
const fs = require("fs");
const { override, fixBabelImports, addLessLoader, addWebpackPlugin } = require('customize-cra');
// const AntDesignThemePlugin = require("antd-theme-webpack-plugin");
const AntDesignThemePlugin = require("../../index");
const AntDesignThemePlugin = require("antd-theme-webpack-plugin");
// const AntDesignThemePlugin = require("../../index");
const { getLessVars } = require('antd-theme-generator');

const themeVariables = getLessVars(path.join(__dirname, './src/styles/vars.less'))
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class AntDesignThemePlugin {
constructor(options) {
const defaulOptions = {
varFile: path.join(__dirname, "../../src/styles/variables.less"),
mainLessFile: path.join(__dirname, "../../src/styles/index.less"),
antDir: path.join(__dirname, "../../node_modules/antd"),
stylesDir: path.join(__dirname, "../../src/styles/antd"),
themeVariables: ["@primary-color"],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "antd-theme-webpack-plugin",
"version": "1.3.5",
"version": "1.3.6",
"description": "A webpack plugin to provide Dynamic Theme for Ant Design",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"deploy": "cd examples/customize-cra && npm run build && gh-pages -d build && cd ../../"
},
"dependencies": {
"antd-theme-generator": "^1.2.3"
"antd-theme-generator": "^1.2.4"
},
"author": {
"name": "mzohaibqc",
Expand Down

0 comments on commit 316a577

Please sign in to comment.