@kaliber/build 0.0.138 → 0.0.139

Sign up to get free protection for your applications and to get access to all the features.
package/lib/build.js CHANGED
@@ -54,6 +54,7 @@ const {
54
54
  publicPath = '/',
55
55
  symlinks = true,
56
56
  webpackLoaders: userDefinedWebpackLoaders = [],
57
+ cssNativeCustomProperties = false,
57
58
  } = {}
58
59
  } = require('@kaliber/config')
59
60
 
@@ -85,11 +86,12 @@ const babelLoader = {
85
86
 
86
87
  const cssLoaderGlobalScope = {
87
88
  loader: 'css-loader',
88
- options: { globalScopeBehaviour: true }
89
+ options: { globalScopeBehaviour: true, nativeCustomProperties: cssNativeCustomProperties }
89
90
  }
90
91
 
91
92
  const cssLoader = {
92
- loader: 'css-loader'
93
+ loader: 'css-loader',
94
+ options: { nativeCustomProperties: cssNativeCustomProperties }
93
95
  }
94
96
 
95
97
  const cssLoaderMinifyOnly = {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.138",
2
+ "version": "0.0.139",
3
3
  "name": "@kaliber/build",
4
4
  "description": "Zero configuration, opinionated webpack / react build setup",
5
5
  "scripts": {
@@ -8,15 +8,15 @@ Color schemes are defined by creating files in a `colorScheme` directory or `col
8
8
  color: var(--color-white);
9
9
 
10
10
  & .color-scheme-icon {
11
- color: color-mod(var(--color-red-dark) alpha(0.4));
11
+ color: var(--color-red-700);
12
12
  }
13
13
 
14
14
  & .color-scheme-exclusion {
15
- color: var(--color-red-light);
15
+ color: var(--color-red-300);
16
16
  }
17
17
 
18
18
  & ::selection {
19
- background-color: var(--color-red-light);
19
+ background-color: var(--color-red-300);
20
20
  }
21
21
  }
22
22
  ```
@@ -68,7 +68,7 @@ Examples of *incorrect* code for this rule:
68
68
  Before:
69
69
  ```css
70
70
  .abc {
71
- color: #AABBCC;
71
+ color: #aabbcc;
72
72
  opacity: 0.5;
73
73
  }
74
74
  ```
@@ -76,8 +76,8 @@ Before:
76
76
  After:
77
77
  ```css
78
78
  .abc {
79
- color: #AABBCC80;
79
+ color: #aabbcc80;
80
80
  /* or */
81
- color: color-mod(#AABBCC alpha(50%));
81
+ color: rgba(170, 187, 204, 0.5);
82
82
  }
83
83
  ```
@@ -51,7 +51,7 @@ html {
51
51
  }
52
52
 
53
53
  body {
54
- color: var(--color-gray-90);
54
+ color: var(--color-gray-900);
55
55
  font-family: var(--font-family-base);
56
56
  font-size: var(--font-size-md);
57
57
  font-weight: var(--font-weight-base-400);
@@ -3,6 +3,9 @@ module.exports = {
3
3
  Warning: do not use this to set values that differ in each environment,
4
4
  only use this for configuration that is the same across all config environments
5
5
  */
6
+ kaliber: {
7
+ cssNativeCustomProperties: true
8
+ },
6
9
  rollbar: {
7
10
  post_client_item: 'get an access token at rollbar.com',
8
11
  }
@@ -1,8 +1,8 @@
1
1
  .component {
2
2
  padding: 20px;
3
3
  border-radius: 4px;
4
- border: 1px solid var(--color-gray-80);
5
- background-color: var(--color-gray-10);
4
+ border: 1px solid var(--color-gray-800);
5
+ background-color: var(--color-gray-100);
6
6
  @media (--viewport-lg) { padding: 40px; }
7
7
 
8
8
  & > *:not(:last-child) { margin-bottom: 40px; }
@@ -1,4 +1,4 @@
1
1
  .component {
2
- background-color: var(--color-gray-70);
2
+ background-color: var(--color-gray-700);
3
3
  padding: 40px 0;
4
4
  }
@@ -0,0 +1,6 @@
1
+ :root {
2
+ --color-gray-100: #f8f8f8;
3
+ --color-gray-700: #4d4d4d;
4
+ --color-gray-800: #1e1e1e;
5
+ --color-gray-900: #1c1c1c;
6
+ }
@@ -1,9 +1,3 @@
1
- :export {
2
- breakpointSm: 480px;
3
- breakpointMd: 768px;
4
- breakpointLg: 1024px;
5
- }
6
-
7
1
  @custom-media --viewport-sm screen and (min-width: 480px);
8
2
  @custom-media --viewport-md screen and (min-width: 768px);
9
3
  @custom-media --viewport-lg screen and (min-width: 1024px);
@@ -0,0 +1 @@
1
+ @custom-selector :--enter :hover, :focus;
@@ -2,5 +2,5 @@
2
2
  --font-family-base: 'Barlow', sans-serif;
3
3
  --font-weight-base-400: 400;
4
4
 
5
- --font-size-md: 18px;
5
+ --font-size-18: 18px;
6
6
  }
@@ -7,7 +7,7 @@ html {
7
7
  }
8
8
 
9
9
  body {
10
- color: var(--color-gray-90);
10
+ color: var(--color-gray-900);
11
11
  font-family: var(--font-family-base);
12
12
  font-size: var(--font-size-md);
13
13
  font-weight: var(--font-weight-base-400);
@@ -1,5 +1,9 @@
1
1
  import '/reset.css'
2
2
  import '/index.css'
3
+ import '/cssGlobal/colors.css'
4
+ import '/cssGlobal/sizes.css'
5
+ import '/cssGlobal/type.css'
6
+
3
7
  import stylesheet from '@kaliber/build/lib/stylesheet'
4
8
  import javascript from '@kaliber/build/lib/javascript'
5
9
  import polyfill from '@kaliber/build/lib/polyfill'
@@ -12,7 +12,6 @@ h4,
12
12
  h5,
13
13
  h6 {
14
14
  margin: 0;
15
- &:not(:last-child) { padding-bottom: 0.8333em; }
16
15
  }
17
16
 
18
17
  address { font-style: normal; }
@@ -8,7 +8,7 @@ const vm = require('vm')
8
8
  const isProduction = process.env.NODE_ENV === 'production'
9
9
 
10
10
  function createPlugins(
11
- { minifyOnly, globalScopeBehaviour, cssGlobalFiles },
11
+ { minifyOnly, globalScopeBehaviour, nativeCustomProperties, cssGlobalFiles },
12
12
  { resolveForImport, resolveForUrlReplace, resolveForImportExportParser }
13
13
  ) {
14
14
 
@@ -22,14 +22,13 @@ function createPlugins(
22
22
  require('postcss-modules-values'),
23
23
  require('postcss-preset-env')({
24
24
  features: {
25
- 'custom-properties': { preserve: false, importFrom: cssGlobalFiles },
25
+ 'custom-properties': !nativeCustomProperties && { preserve: false, importFrom: cssGlobalFiles },
26
26
  'custom-media-queries': { preserve: false, importFrom: cssGlobalFiles },
27
27
  'custom-selectors': { preserve: false, importFrom: cssGlobalFiles },
28
28
  'media-query-ranges': true,
29
29
  'nesting-rules': true,
30
30
  'hexadecimal-alpha-notation': true,
31
31
  'color-functional-notation': true,
32
- 'color-mod-function': true,
33
32
  'font-variant-property': true,
34
33
  'all-property': true,
35
34
  'any-link-pseudo-class': true,
@@ -60,12 +59,12 @@ module.exports = function CssLoader(source, map) {
60
59
  const callback = this.async()
61
60
 
62
61
  const loaderOptions = loaderUtils.getOptions(this) || {}
63
- const { minifyOnly = false, globalScopeBehaviour = false } = loaderOptions
62
+ const { minifyOnly = false, globalScopeBehaviour = false, nativeCustomProperties = false } = loaderOptions
64
63
 
65
64
  const cssGlobalFiles = cachedFindCssGlobalFiles(this)
66
65
  cssGlobalFiles.forEach(x => this.addDependency(x))
67
66
 
68
- const plugins = getPlugins(this, { minifyOnly, globalScopeBehaviour, cssGlobalFiles })
67
+ const plugins = getPlugins(this, { minifyOnly, globalScopeBehaviour, nativeCustomProperties, cssGlobalFiles })
69
68
  const filename = relative(this.rootContext, this.resourcePath)
70
69
  const options = {
71
70
  from: this.resourcePath,
@@ -109,12 +108,12 @@ module.exports = function CssLoader(source, map) {
109
108
  }
110
109
  }
111
110
 
112
- function getPlugins(loaderContext, { minifyOnly, globalScopeBehaviour, cssGlobalFiles }) {
111
+ function getPlugins(loaderContext, { minifyOnly, globalScopeBehaviour, nativeCustomProperties, cssGlobalFiles }) {
113
112
  const key = `plugins${minifyOnly ? '-minifyOnly' : ''}${globalScopeBehaviour ? '-globalScope' : ''}`
114
113
 
115
- return cachedInConmpilation(loaderContext, key, () => {
114
+ return cachedInCompilation(loaderContext, key, () => {
116
115
  const handlers = createHandlers(loaderContext)
117
- const plugins = createPlugins({ minifyOnly, globalScopeBehaviour, cssGlobalFiles }, handlers)
116
+ const plugins = createPlugins({ minifyOnly, globalScopeBehaviour, nativeCustomProperties, cssGlobalFiles }, handlers)
118
117
  return plugins
119
118
  })
120
119
  }
@@ -149,7 +148,7 @@ function createHandlers(loaderContext) {
149
148
 
150
149
  function executeModuleAt(url, source) {
151
150
  const key = `module-${url}`
152
- return cachedInConmpilation(loaderContext, key, () => {
151
+ return cachedInCompilation(loaderContext, key, () => {
153
152
 
154
153
  const sandbox = {
155
154
  module: {},
@@ -162,12 +161,12 @@ function createHandlers(loaderContext) {
162
161
  }
163
162
 
164
163
  function cachedFindCssGlobalFiles(loaderContext) {
165
- return cachedInConmpilation(loaderContext, 'global-css-files', () =>
164
+ return cachedInCompilation(loaderContext, 'global-css-files', () =>
166
165
  findCssGlobalFiles(loaderContext.rootContext)
167
166
  )
168
167
  }
169
168
 
170
- function cachedInConmpilation(loaderContext, key, f) {
169
+ function cachedInCompilation(loaderContext, key, f) {
171
170
  const c = loaderContext._compilation
172
171
  const cache = c.kaliberCache || (c.kaliberCache = {})
173
172
  if (cache[key]) return cache[key]
@@ -1,6 +0,0 @@
1
- :root {
2
- --color-gray-10: #f8f8f8;
3
- --color-gray-70: #4d4d4d;
4
- --color-gray-80: #1e1e1e;
5
- --color-gray-90: #1c1c1c;
6
- }