@davidwells/config-postcss 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +3 -2
- package/src/print.js +49 -0
- package/src/printColors.js +0 -26
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const webpackLoaderOptionUtil = require('./webpackLoaderOptionUtil')
|
|
|
6
6
|
const mixins = require('./_mixins')
|
|
7
7
|
const variables = require('./_variables')
|
|
8
8
|
const functions = require('./_functions')
|
|
9
|
-
const printColors = require('./
|
|
9
|
+
const { printVariables, printColors } = require('./print')
|
|
10
10
|
|
|
11
11
|
module.exports = {
|
|
12
12
|
getPostCSSConfig,
|
|
@@ -16,5 +16,6 @@ module.exports = {
|
|
|
16
16
|
mixins,
|
|
17
17
|
variables,
|
|
18
18
|
functions,
|
|
19
|
-
|
|
19
|
+
printVariables,
|
|
20
|
+
printColors
|
|
20
21
|
}
|
package/src/print.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const safeChalk = require('safe-chalk')
|
|
2
|
+
const isColor = require('is-color')
|
|
3
|
+
const { isHex } = require('is-color')
|
|
4
|
+
const rgbHex = require('rgb-hex')
|
|
5
|
+
|
|
6
|
+
const args = (process.argv && process.argv[2]) ? process.argv[2] : ''
|
|
7
|
+
const DISABLE_COLORS = (args.indexOf('--json') > -1) || process.env.NO_COLORS
|
|
8
|
+
const chalk = safeChalk(DISABLE_COLORS)
|
|
9
|
+
|
|
10
|
+
// Hot reload webpack files for PostCSS
|
|
11
|
+
function printVariables(variables = {}) {
|
|
12
|
+
if (!variables) {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
console.log('CSS variables:')
|
|
16
|
+
Object.keys(variables).forEach((key) => {
|
|
17
|
+
const val = variables[key]
|
|
18
|
+
if (val && typeof val === 'string') {
|
|
19
|
+
console.log(`$${key} - ${val}`)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
console.log('Colors:')
|
|
23
|
+
printColors(variables)
|
|
24
|
+
console.log('👆 CSS variables usable via ${nameOfThing} in css files') // eslint-disable-line
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Hot reload webpack files for PostCSS
|
|
28
|
+
function printColors(variables = {}) {
|
|
29
|
+
if (!variables) {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
const colors = []
|
|
33
|
+
Object.keys(variables).forEach((key) => {
|
|
34
|
+
const value = variables[key]
|
|
35
|
+
if (value && typeof value === 'string' && isColor(value)) {
|
|
36
|
+
const color = (isHex(value)) ? value : `#${rgbHex(value)}`
|
|
37
|
+
colors.push({ key, value, color })
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
colors.forEach(({ key, value, color }) => {
|
|
41
|
+
console.log(`${chalk.hex(color).bold('████████████')} $${key} - ${value}`)
|
|
42
|
+
})
|
|
43
|
+
return colors
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
printVariables,
|
|
48
|
+
printColors
|
|
49
|
+
}
|
package/src/printColors.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const safeChalk = require('safe-chalk')
|
|
2
|
-
const isColor = require('is-color')
|
|
3
|
-
const { isHex } = require('is-color')
|
|
4
|
-
const rgbHex = require('rgb-hex')
|
|
5
|
-
|
|
6
|
-
const args = (process.argv && process.argv[2]) ? process.argv[2] : ''
|
|
7
|
-
const DISABLE_COLORS = (args.indexOf('--json') > -1) || process.env.NO_COLORS
|
|
8
|
-
const chalk = safeChalk(DISABLE_COLORS)
|
|
9
|
-
|
|
10
|
-
// Hot reload webpack files for PostCSS
|
|
11
|
-
module.exports = function printColors(variables = {}) {
|
|
12
|
-
if (!variables) {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
console.log('CSS variables:')
|
|
16
|
-
console.log(variables)
|
|
17
|
-
console.log('Colors:')
|
|
18
|
-
Object.keys(variables).forEach((key) => {
|
|
19
|
-
const val = variables[key]
|
|
20
|
-
if (val && typeof val === 'string' && isColor(val)) {
|
|
21
|
-
const color = (isHex(val)) ? val : `#${rgbHex(val)}`
|
|
22
|
-
console.log(`${chalk.hex(color).bold('████████████')} $${key} - ${val}`)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
console.log('👆 CSS variables usable via ${nameOfThing} in css files') // eslint-disable-line
|
|
26
|
-
}
|