@davidwells/config-postcss 0.1.6 → 0.2.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@davidwells/config-postcss",
3
- "version": "0.1.6",
3
+ "version": "0.2.1",
4
4
  "description": "Reusable postcss config",
5
5
  "author": "DavidWells",
6
6
  "license": "MIT",
@@ -22,41 +22,30 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@davidwells/postcss-math": "^1.0.3",
25
- "autoprefixer": "^9.8.6",
25
+ "autoprefixer": "^10.4.20",
26
26
  "color": "^3.1.3",
27
- "cssnano": "^4.1.10",
27
+ "css-color-function": "^1.3.3",
28
+ "cssnano": "^7.0.6",
28
29
  "dedent": "^0.7.0",
29
30
  "globby": "^11.0.1",
30
31
  "is-color": "^1.0.2",
31
32
  "is-css-unit": "^1.0.0",
32
33
  "kleur": "^4.1.3",
33
- "pleeease-filters": "^4.0.0",
34
- "postcss": "^8.3.0",
35
- "postcss-calc": "^7.0.5",
36
- "postcss-cli": "^8.3.1",
37
- "postcss-color-function": "^4.1.0",
38
- "postcss-combine-media-query": "^1.0.1",
39
- "postcss-comment": "^2.0.0",
40
- "postcss-custom-media": "^7.0.8",
41
- "postcss-custom-properties": "^10.0.0",
42
- "postcss-custom-selectors": "^5.1.2",
43
- "postcss-extract-media-query": "^2.0.0",
44
- "postcss-flexbugs-fixes": "^4.2.1",
45
- "postcss-functions": "^3.0.0",
46
- "postcss-import": "^12.0.1",
47
- "postcss-initial": "3.0.2",
48
- "postcss-media-minmax": "^4.0.0",
49
- "postcss-mixins": "6.2.3",
50
- "postcss-nested": "4.2.3",
51
- "postcss-nested-ancestors": "^2.0.0",
52
- "postcss-nesting": "^7.0.1",
53
- "postcss-preset-env": "^7.4.1",
54
- "postcss-reporter": "^7.0.2",
55
- "postcss-selector-matches": "^4.0.0",
56
- "postcss-selector-not": "^4.0.0",
57
- "postcss-simple-vars": "5.0.2",
58
- "postcss-sort-media-queries": "^2.3.15",
59
- "postcss-sorting": "^6.0.0",
34
+ "postcss": "^8.4.47",
35
+ "postcss-calc": "^10.1.0",
36
+ "postcss-custom-media": "^11.0.5",
37
+ "postcss-custom-properties": "^14.0.4",
38
+ "postcss-flexbugs-fixes": "^5.0.2",
39
+ "postcss-functions": "^4.0.2",
40
+ "postcss-import": "^16.1.0",
41
+ "postcss-media-minmax": "^5.0.0",
42
+ "postcss-mixins": "^11.0.3",
43
+ "postcss-nested": "^7.0.2",
44
+ "postcss-nested-ancestors": "^3.0.0",
45
+ "postcss-nesting": "^13.0.1",
46
+ "postcss-preset-env": "^7.8.3",
47
+ "postcss-simple-vars": "^6.0.3",
48
+ "postcss-value-parser": "^4.2.0",
60
49
  "rgb-hex": "^3.0.0",
61
50
  "safe-chalk": "^1.0.0",
62
51
  "validate-color": "^2.1.1"
@@ -46,8 +46,8 @@ module.exports = function getPostCSSPlugins({ variables, mixins, functions, env
46
46
  'postcss-functions': {
47
47
  functions: functions
48
48
  },
49
- /* https://github.com/postcss/postcss-color-function */
50
- 'postcss-color-function': {},
49
+ /* Inline PostCSS 8 port of postcss-color-function (legacy color() adjuster syntax) */
50
+ '@davidwells/config-postcss/src/plugins/color-function': {},
51
51
  /* https://github.com/postcss/postcss-custom-properties */
52
52
  'postcss-custom-properties': {},
53
53
  /* https://github.com/postcss/postcss-custom-media */
@@ -64,12 +64,6 @@ module.exports = function getPostCSSPlugins({ variables, mixins, functions, env
64
64
  'postcss-nesting': {},
65
65
  /* https://github.com/postcss/postcss-nested */
66
66
  'postcss-nested': {},
67
- /* https://github.com/iamvdo/pleeease-filters */
68
- 'pleeease-filters': {},
69
- /* https://github.com/postcss/postcss-selector-matches */
70
- 'postcss-selector-matches': {},
71
- /* https://github.com/postcss/postcss-selector-not */
72
- 'postcss-selector-not': {},
73
67
  /* https://github.com/luisrudge/postcss-flexbugs-fixes */
74
68
  'postcss-flexbugs-fixes': {},
75
69
  // /* https://github.com/maximkoretskiy/postcss-initial */
@@ -0,0 +1,41 @@
1
+ // PostCSS 8 port of postcss-color-function (abandoned, postcss 6).
2
+ // Transforms the legacy color() adjuster syntax, e.g. color(#0685c4 lightness(40%)),
3
+ // into a computed rgb()/hex value via the css-color-function library.
4
+ const parser = require('postcss-value-parser')
5
+ const colorFn = require('css-color-function')
6
+
7
+ function transformColor(string) {
8
+ return parser(string).walk((node) => {
9
+ if (node.type !== 'function' || node.value !== 'color') {
10
+ return
11
+ }
12
+ node.value = colorFn.convert(parser.stringify(node))
13
+ node.type = 'word'
14
+ }).toString()
15
+ }
16
+
17
+ module.exports = (opts = {}) => {
18
+ const preserveCustomProps = opts.preserveCustomProps !== false
19
+ return {
20
+ postcssPlugin: 'postcss-color-function',
21
+ Declaration(decl) {
22
+ if (!decl.value || decl.value.indexOf('color(') === -1) {
23
+ return
24
+ }
25
+ // Can't resolve color() that references a var() at build time
26
+ if (decl.value.indexOf('var(') !== -1) {
27
+ if (!preserveCustomProps) {
28
+ decl.remove()
29
+ }
30
+ return
31
+ }
32
+ try {
33
+ decl.value = transformColor(decl.value)
34
+ } catch (error) {
35
+ // Leave the value untouched if it can't be parsed/converted
36
+ console.warn('postcss-color-function: could not convert', decl.value, error.message)
37
+ }
38
+ },
39
+ }
40
+ }
41
+ module.exports.postcss = true
@@ -1,11 +1,10 @@
1
- /* https://github.com/zoubin/postcss-comment - Allow postcss to support inline comments. */
2
- const commentParser = require('postcss-comment')
3
-
4
1
  module.exports = function loaderOptions(postcssPlugins) {
5
2
  return (postcssLoaderOptions, { env, paths }) => {
6
3
  /* Hot reload modules */
7
4
  postcssLoaderOptions.map = env === 'development' ? { inline: true } : false
8
- postcssLoaderOptions.parser = commentParser
5
+ /* Inline-comment parser, lazily required so consumers that don't use it
6
+ (e.g. Next.js) don't need postcss-comment installed. */
7
+ postcssLoaderOptions.parser = require('postcss-comment')
9
8
  postcssLoaderOptions.plugins = postcssPlugins
10
9
  return postcssLoaderOptions
11
10
  }