antd-theme-generator
Advanced tools
Comparing version 1.1.1 to 1.1.2
44
index.js
@@ -8,2 +8,3 @@ const fs = require("fs"); | ||
const hash = require("hash.js"); | ||
const NpmImportPlugin = require('less-plugin-npm-import'); | ||
@@ -148,3 +149,4 @@ let hashCache = ""; | ||
paths: paths, | ||
javascriptEnabled: true | ||
javascriptEnabled: true, | ||
plugins: [new NpmImportPlugin({ prefix: '~' })] | ||
}); | ||
@@ -217,2 +219,26 @@ } | ||
function getCssModulesStyles(stylesDir, antdStylesDir) { | ||
const styles = glob.sync(path.join(stylesDir, './**/*.less')); | ||
return Promise.all( | ||
styles.map(p => | ||
less | ||
.render(fs.readFileSync(p).toString(), { | ||
paths: [ | ||
stylesDir, | ||
antdStylesDir, | ||
], | ||
filename: path.resolve(p), | ||
javascriptEnabled: true, | ||
plugins: [new NpmImportPlugin({ prefix: '~' })], | ||
}) | ||
.catch(() => '\n') | ||
) | ||
) | ||
.then(csss => csss.map(c => c.css).join('\n')) | ||
.catch(err => { | ||
console.log('Error', err); | ||
return ''; | ||
}); | ||
} | ||
/* | ||
@@ -230,2 +256,3 @@ This is main function which call all other functions to generate color.less file which contins all color | ||
outputFilePath, | ||
cssModules = false, | ||
themeVariables = ['@primary-color'] | ||
@@ -316,7 +343,12 @@ }) { | ||
content = `${content}\n${colorsLess}`; | ||
return render(content, lessPaths).then(({ css }) => [ | ||
css, | ||
mappings, | ||
colorsLess | ||
]); | ||
return render(content, lessPaths).then(({ css }) => { | ||
return getCssModulesStyles(stylesDir, antdStylesDir).then(customCss => { | ||
return [ | ||
`${customCss}\n${css}`, | ||
mappings, | ||
colorsLess | ||
]; | ||
}) | ||
}); | ||
}) | ||
@@ -323,0 +355,0 @@ .then(([css, mappings, colorsLess]) => { |
{ | ||
"name": "antd-theme-generator", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "This a script to generate color specific styles less file and which you can use to change theme dynamically in browser", | ||
@@ -12,4 +12,5 @@ "main": "index.js", | ||
"less": "^2.7.2", | ||
"less-bundle-promise": "1.0.6", | ||
"postcss": "^6.0.21" | ||
"less-bundle-promise": "1.0.7", | ||
"postcss": "^6.0.21", | ||
"less-plugin-npm-import": "^2.1.0" | ||
}, | ||
@@ -16,0 +17,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28125
4
371
5
+ Addedless-bundle-promise@1.0.7(transitive)
+ Addedless-plugin-npm-import@2.1.0(transitive)
+ Addedpromise@7.0.4(transitive)
+ Addedresolve@1.1.7(transitive)
- Removedless-bundle-promise@1.0.6(transitive)
Updatedless-bundle-promise@1.0.7