@symbo.ls/init 2.10.31 → 2.10.49
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/index.js +25 -6
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import {
|
|
4
4
|
set,
|
|
5
5
|
getActiveConfig,
|
|
6
|
-
getFontFaceString
|
|
6
|
+
getFontFaceString,
|
|
7
|
+
appendSVGSprite,
|
|
8
|
+
appendIconsSprite
|
|
7
9
|
} from '@symbo.ls/scratch'
|
|
8
10
|
|
|
9
11
|
import { isObject, deepMerge } from '@domql/utils'
|
|
@@ -15,7 +17,7 @@ import DYNAMIC_JSON from './dynamic.json'
|
|
|
15
17
|
|
|
16
18
|
const CONFIG = getActiveConfig()
|
|
17
19
|
|
|
18
|
-
const
|
|
20
|
+
const mergeWithLocalFile = (config = CONFIG, RC_FILE) => {
|
|
19
21
|
const rcfile = isObject(RC_FILE) ? RC_FILE : DYNAMIC_JSON || {}
|
|
20
22
|
return deepMerge(config, rcfile)
|
|
21
23
|
}
|
|
@@ -23,17 +25,23 @@ const prepareInit = (config = CONFIG, RC_FILE) => {
|
|
|
23
25
|
const SET_OPTIONS = {
|
|
24
26
|
emotion: defaultEmotion,
|
|
25
27
|
useVariable: true,
|
|
26
|
-
useReset: true
|
|
28
|
+
useReset: true,
|
|
29
|
+
useFontImport: true,
|
|
30
|
+
useIconSprite: true,
|
|
31
|
+
useSvgSprite: true
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
export const init = (config, RC_FILE, options = SET_OPTIONS) => {
|
|
30
|
-
const resultConfig =
|
|
35
|
+
const resultConfig = mergeWithLocalFile(config, RC_FILE)
|
|
31
36
|
const emotion = options.emotion || defaultEmotion
|
|
32
37
|
|
|
33
38
|
const conf = set({
|
|
34
39
|
verbose: options.verbose,
|
|
35
40
|
useReset: options.useReset,
|
|
41
|
+
useFontImport: options.useFontImport,
|
|
36
42
|
useVariable: options.useVariable,
|
|
43
|
+
useSvgSprite: options.useSvgSprite,
|
|
44
|
+
useIconSprite: options.useIconSprite,
|
|
37
45
|
...resultConfig
|
|
38
46
|
}, { newConfig: options.newConfig })
|
|
39
47
|
|
|
@@ -41,16 +49,27 @@ export const init = (config, RC_FILE, options = SET_OPTIONS) => {
|
|
|
41
49
|
|
|
42
50
|
const useReset = conf.useReset
|
|
43
51
|
const useVariable = conf.useVariable
|
|
52
|
+
const useFontImport = conf.useFontImport
|
|
53
|
+
const useSvgSprite = conf.useSvgSprite
|
|
54
|
+
const hasSvgs = config.svg || config.SVG
|
|
55
|
+
const useIconSprite = conf.useIconSprite
|
|
56
|
+
const hasIcons = config.icons || config.ICONS
|
|
44
57
|
|
|
45
|
-
emotion.injectGlobal(FontFace)
|
|
58
|
+
if (useFontImport) emotion.injectGlobal(FontFace)
|
|
46
59
|
if (useVariable) emotion.injectGlobal({ ':root': conf.CSS_VARS })
|
|
47
60
|
if (useReset) emotion.injectGlobal(conf.RESET)
|
|
48
61
|
|
|
62
|
+
if (hasSvgs) appendSVGSprite(hasSvgs, { document: options.document })
|
|
63
|
+
else if (useSvgSprite) appendSVGSprite(conf.SVG, { document: options.document })
|
|
64
|
+
|
|
65
|
+
if (hasIcons) appendIconsSprite(hasIcons, { document: options.document })
|
|
66
|
+
else if (useIconSprite) appendIconsSprite(conf.ICONS, { document: options.document })
|
|
67
|
+
|
|
49
68
|
return conf
|
|
50
69
|
}
|
|
51
70
|
|
|
52
71
|
export const updateReset = (config, RC_FILE, options = { emotion: defaultEmotion }) => {
|
|
53
|
-
const resultConfig =
|
|
72
|
+
const resultConfig = mergeWithLocalFile(config, RC_FILE)
|
|
54
73
|
const conf = set({
|
|
55
74
|
verbose: false,
|
|
56
75
|
...resultConfig
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/init",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.49",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "6c85785f0f1488d8d20595000faa787994aea2dc",
|
|
6
6
|
"source": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"targets": {
|