@eightshift/frontend-libs-tailwind 3.1.2 → 3.3.0
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/.claude/settings.local.json +7 -0
- package/.github/workflows/ci.yml +4 -3
- package/.husky/pre-commit +3 -1
- package/.prettierrc +2 -4
- package/CHANGELOG.md +41 -2
- package/bun.lock +124 -66
- package/linters/stylelint.config.js +1 -1
- package/package.json +16 -20
- package/schemas/globalManifest.json +6 -14
- package/scripts/components/block-inserter.js +2 -13
- package/scripts/components/file-picker.js +2 -21
- package/scripts/components/link-section-editor.js +1 -5
- package/scripts/components/picker-placeholder.js +2 -14
- package/scripts/components/server-side-render.js +1 -4
- package/scripts/components/settings/settings.js +2 -8
- package/scripts/editor/attributes.js +4 -23
- package/scripts/editor/editor.js +2 -4
- package/scripts/editor/fetch.js +3 -23
- package/scripts/editor/index.js +1 -8
- package/scripts/editor/options.js +1 -3
- package/scripts/editor/registration.js +22 -98
- package/scripts/editor/store.js +0 -19
- package/scripts/editor/tailwindcss.js +76 -121
- package/scripts/helpers/index.js +1 -7
- package/scripts/index.js +2 -15
- package/scripts/plugins/yoast-seo.js +1 -5
- package/webpack/base.mjs +14 -27
- package/webpack/helpers.mjs +5 -23
- package/webpack/index.mjs +2 -7
- package/webpack/project.mjs +2 -8
- package/webpack/responsive-compiler.mjs +165 -0
package/scripts/editor/store.js
CHANGED
|
@@ -10,7 +10,6 @@ const DEFAULT_STATE = {
|
|
|
10
10
|
components: {},
|
|
11
11
|
config: {
|
|
12
12
|
useWrapper: true,
|
|
13
|
-
useLegacyComponents: true,
|
|
14
13
|
},
|
|
15
14
|
wrapper: {},
|
|
16
15
|
variations: {},
|
|
@@ -45,9 +44,6 @@ const selectors = {
|
|
|
45
44
|
getConfigUseWrapper(state) {
|
|
46
45
|
return state.config.useWrapper;
|
|
47
46
|
},
|
|
48
|
-
getConfigUseLegacyComponents(state) {
|
|
49
|
-
return state.config.useLegacyComponents;
|
|
50
|
-
},
|
|
51
47
|
getWrapper(state) {
|
|
52
48
|
return state.wrapper;
|
|
53
49
|
},
|
|
@@ -94,12 +90,6 @@ const actions = {
|
|
|
94
90
|
config,
|
|
95
91
|
};
|
|
96
92
|
},
|
|
97
|
-
setConfigUseLegacyComponents(config) {
|
|
98
|
-
return {
|
|
99
|
-
type: 'SET_CONFIG_USE_LEGACY_COMPONENTS',
|
|
100
|
-
config,
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
93
|
setWrapper(wrapper) {
|
|
104
94
|
return {
|
|
105
95
|
type: 'SET_WRAPPER',
|
|
@@ -150,15 +140,6 @@ const reducer = (state = DEFAULT_STATE, action) => {
|
|
|
150
140
|
},
|
|
151
141
|
};
|
|
152
142
|
}
|
|
153
|
-
case 'SET_CONFIG_USE_LEGACY_COMPONENTS': {
|
|
154
|
-
return {
|
|
155
|
-
...state,
|
|
156
|
-
config: {
|
|
157
|
-
...state.config,
|
|
158
|
-
useLegacyComponents: action.config,
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
143
|
case 'SET_WRAPPER': {
|
|
163
144
|
return {
|
|
164
145
|
...state,
|
|
@@ -26,8 +26,7 @@ export const getTwPart = (part, manifest, ...custom) => {
|
|
|
26
26
|
return clsx(...custom);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let partClasses =
|
|
30
|
-
manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
|
|
29
|
+
let partClasses = manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
|
|
31
30
|
|
|
32
31
|
if (Array.isArray(partClasses)) {
|
|
33
32
|
partClasses = partClasses.join(' ');
|
|
@@ -62,53 +61,49 @@ export const getTwDynamicPart = (part, attributes, manifest, ...custom) => {
|
|
|
62
61
|
return clsx(...custom);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
const baseClasses =
|
|
66
|
-
manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
|
|
64
|
+
const baseClasses = manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
|
|
67
65
|
|
|
68
|
-
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce(
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
66
|
+
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce((current, [attributeName, { responsive, twClasses, twClassesEditor, part: partName }]) => {
|
|
67
|
+
if (partName !== part) {
|
|
68
|
+
return current;
|
|
69
|
+
}
|
|
73
70
|
|
|
74
|
-
|
|
71
|
+
const value = checkAttr(attributeName, attributes, manifest, true);
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
if (!value) {
|
|
74
|
+
return current;
|
|
75
|
+
}
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
if (!responsive) {
|
|
78
|
+
const currentClasses = twClassesEditor?.[value] ?? twClasses?.[value];
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return [...current, currentClasses];
|
|
80
|
+
if (Array.isArray(currentClasses)) {
|
|
81
|
+
return [...current, ...currentClasses];
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
return [...current, currentClasses];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const responsiveClasses = Object.keys(value).reduce((curr, breakpoint) => {
|
|
88
|
+
if (breakpoint === '_desktopFirst') {
|
|
89
|
+
return curr;
|
|
90
|
+
}
|
|
94
91
|
|
|
95
|
-
|
|
92
|
+
let currentClasses = twClassesEditor?.[value[breakpoint]] ?? twClasses?.[value[breakpoint]];
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
if (!Array.isArray(currentClasses)) {
|
|
95
|
+
currentClasses = [currentClasses];
|
|
96
|
+
}
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
if (breakpoint === '_default') {
|
|
99
|
+
return [...curr, ...currentClasses];
|
|
100
|
+
}
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
return [...curr, ...currentClasses.split(' ').map((currentClass) => `${breakpoint}:${currentClass}`)];
|
|
103
|
+
}, []);
|
|
107
104
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
[],
|
|
111
|
-
);
|
|
105
|
+
return [...current, ...responsiveClasses];
|
|
106
|
+
}, []);
|
|
112
107
|
|
|
113
108
|
return clsx(baseClasses, ...mainClasses, ...custom);
|
|
114
109
|
};
|
|
@@ -142,50 +137,47 @@ export const getTwClasses = (attributes, manifest, ...custom) => {
|
|
|
142
137
|
baseClasses = baseClasses.join(' ');
|
|
143
138
|
}
|
|
144
139
|
|
|
145
|
-
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce(
|
|
146
|
-
(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const value = checkAttr(attributeName, attributes, manifest, true);
|
|
140
|
+
const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce((current, [attributeName, { responsive, twClasses, twClassesEditor, part: partName }]) => {
|
|
141
|
+
if (partName) {
|
|
142
|
+
return current;
|
|
143
|
+
}
|
|
152
144
|
|
|
153
|
-
|
|
154
|
-
return current;
|
|
155
|
-
}
|
|
145
|
+
const value = checkAttr(attributeName, attributes, manifest, true);
|
|
156
146
|
|
|
157
|
-
|
|
158
|
-
|
|
147
|
+
if (!value) {
|
|
148
|
+
return current;
|
|
149
|
+
}
|
|
159
150
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
151
|
+
if (!responsive) {
|
|
152
|
+
let currentClasses = twClassesEditor?.[value] ?? twClasses?.[value];
|
|
163
153
|
|
|
164
|
-
|
|
154
|
+
if (Array.isArray(currentClasses)) {
|
|
155
|
+
currentClasses = currentClasses.join(' ');
|
|
165
156
|
}
|
|
166
157
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return curr;
|
|
170
|
-
}
|
|
158
|
+
return [...current, currentClasses];
|
|
159
|
+
}
|
|
171
160
|
|
|
172
|
-
|
|
161
|
+
const responsiveClasses = Object.keys(value).reduce((curr, breakpoint) => {
|
|
162
|
+
if (breakpoint === '_desktopFirst') {
|
|
163
|
+
return curr;
|
|
164
|
+
}
|
|
173
165
|
|
|
174
|
-
|
|
175
|
-
currentClasses = [currentClasses];
|
|
176
|
-
}
|
|
166
|
+
let currentClasses = twClassesEditor?.[value[breakpoint]] ?? twClasses?.[value[breakpoint]];
|
|
177
167
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
168
|
+
if (!Array.isArray(currentClasses)) {
|
|
169
|
+
currentClasses = [currentClasses];
|
|
170
|
+
}
|
|
181
171
|
|
|
182
|
-
|
|
183
|
-
|
|
172
|
+
if (breakpoint === '_default') {
|
|
173
|
+
return [...curr, ...currentClasses];
|
|
174
|
+
}
|
|
184
175
|
|
|
185
|
-
return [...
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
|
|
176
|
+
return [...curr, ...currentClasses.map((currentClass) => `${breakpoint}:${currentClass}`)];
|
|
177
|
+
}, []);
|
|
178
|
+
|
|
179
|
+
return [...current, ...responsiveClasses];
|
|
180
|
+
}, []);
|
|
189
181
|
|
|
190
182
|
const combinationClasses =
|
|
191
183
|
manifest?.tailwind?.combinations?.reduce((current, { attributes: conditions, twClasses, twClassesEditor }) => {
|
|
@@ -316,14 +308,14 @@ export const generateOptionsFromValue = (value, getLabel = (v) => v) => {
|
|
|
316
308
|
|
|
317
309
|
// Utilities
|
|
318
310
|
function* extractKeys(obj, parentKey = '', isResponsive = false) {
|
|
319
|
-
|
|
320
|
-
let resultKey =
|
|
311
|
+
const responsive = obj['responsive'] === true ? true : isResponsive;
|
|
312
|
+
let resultKey = responsive ? 'responsive' : 'regular';
|
|
321
313
|
|
|
322
314
|
for (let key in obj) {
|
|
323
315
|
let newKey = parentKey ? `${parentKey}.${key}` : key;
|
|
324
316
|
|
|
325
317
|
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
326
|
-
yield* extractKeys(obj[key], newKey,
|
|
318
|
+
yield* extractKeys(obj[key], newKey, responsive);
|
|
327
319
|
} else if (newKey.includes('twClasses')) {
|
|
328
320
|
if (typeof obj[key] === 'object') {
|
|
329
321
|
for (let subKey in obj[key]) {
|
|
@@ -374,15 +366,9 @@ const processOption = (partName, optionValue, defs) => {
|
|
|
374
366
|
|
|
375
367
|
// Non-responsive options.
|
|
376
368
|
if (!isResponsive) {
|
|
377
|
-
const rawValueBase =
|
|
378
|
-
defs?.twClassesEditorOnly?.[optionValue] ??
|
|
379
|
-
defs?.twClasses?.[optionValue] ??
|
|
380
|
-
defs?.[partName]?.twClassesEditorOnly?.[optionValue] ??
|
|
381
|
-
defs?.[partName]?.twClasses?.[optionValue] ??
|
|
382
|
-
'';
|
|
369
|
+
const rawValueBase = defs?.twClassesEditorOnly?.[optionValue] ?? defs?.twClasses?.[optionValue] ?? defs?.[partName]?.twClassesEditorOnly?.[optionValue] ?? defs?.[partName]?.twClasses?.[optionValue] ?? '';
|
|
383
370
|
|
|
384
|
-
const rawValueEditor =
|
|
385
|
-
defs?.twClassesEditor?.[optionValue] ?? defs?.[partName]?.twClassesEditor?.[optionValue] ?? '';
|
|
371
|
+
const rawValueEditor = defs?.twClassesEditor?.[optionValue] ?? defs?.[partName]?.twClassesEditor?.[optionValue] ?? '';
|
|
386
372
|
|
|
387
373
|
return clsx(unifyClasses(rawValueBase), unifyClasses(rawValueEditor));
|
|
388
374
|
}
|
|
@@ -397,15 +383,9 @@ const processOption = (partName, optionValue, defs) => {
|
|
|
397
383
|
continue;
|
|
398
384
|
}
|
|
399
385
|
|
|
400
|
-
const rawValueBase =
|
|
401
|
-
defs?.twClassesEditorOnly?.[breakpointValue] ??
|
|
402
|
-
defs?.twClasses?.[breakpointValue] ??
|
|
403
|
-
defs?.[partName]?.twClassesEditorOnly?.[breakpointValue] ??
|
|
404
|
-
defs?.[partName]?.twClasses?.[breakpointValue] ??
|
|
405
|
-
'';
|
|
386
|
+
const rawValueBase = defs?.twClassesEditorOnly?.[breakpointValue] ?? defs?.twClasses?.[breakpointValue] ?? defs?.[partName]?.twClassesEditorOnly?.[breakpointValue] ?? defs?.[partName]?.twClasses?.[breakpointValue] ?? '';
|
|
406
387
|
|
|
407
|
-
const rawValueEditor =
|
|
408
|
-
defs?.twClassesEditor?.[breakpointValue] ?? defs?.[partName]?.twClassesEditor?.[breakpointValue] ?? '';
|
|
388
|
+
const rawValueEditor = defs?.twClassesEditor?.[breakpointValue] ?? defs?.[partName]?.twClassesEditor?.[breakpointValue] ?? '';
|
|
409
389
|
|
|
410
390
|
if (breakpoint === '_default') {
|
|
411
391
|
optionClasses = [...optionClasses, unifyClasses(rawValueBase), unifyClasses(rawValueEditor)];
|
|
@@ -457,25 +437,16 @@ const processCombination = (partName, combo, attributes, manifest) => {
|
|
|
457
437
|
return '';
|
|
458
438
|
}
|
|
459
439
|
|
|
460
|
-
const rawValueBase =
|
|
461
|
-
combo?.output?.[partName]?.twClassesEditorOnly ??
|
|
462
|
-
combo?.output?.[partName]?.twClasses ??
|
|
463
|
-
combo?.twClassesEditorOnly ??
|
|
464
|
-
combo?.twClasses ??
|
|
465
|
-
'';
|
|
440
|
+
const rawValueBase = combo?.output?.[partName]?.twClassesEditorOnly ?? combo?.output?.[partName]?.twClasses ?? combo?.twClassesEditorOnly ?? combo?.twClasses ?? '';
|
|
466
441
|
|
|
467
442
|
const rawValueEditor = combo?.output?.[partName]?.twClassesEditor ?? combo?.twClassesEditor ?? '';
|
|
468
443
|
|
|
469
444
|
if (!Array.isArray(rawValueBase) && typeof rawValueBase !== 'string') {
|
|
470
|
-
throw new Error(
|
|
471
|
-
'Combination classes/editor-only classes were not defined correctly. Please check the combination definition in the manifest.',
|
|
472
|
-
);
|
|
445
|
+
throw new Error('Combination classes/editor-only classes were not defined correctly. Please check the combination definition in the manifest.');
|
|
473
446
|
}
|
|
474
447
|
|
|
475
448
|
if (!Array.isArray(rawValueEditor) && typeof rawValueEditor !== 'string') {
|
|
476
|
-
throw new Error(
|
|
477
|
-
'Combination editor classes were not defined correctly. Please check the combination definition in the manifest.',
|
|
478
|
-
);
|
|
449
|
+
throw new Error('Combination editor classes were not defined correctly. Please check the combination definition in the manifest.');
|
|
479
450
|
}
|
|
480
451
|
|
|
481
452
|
return clsx(unifyClasses(rawValueBase), unifyClasses(rawValueEditor));
|
|
@@ -508,24 +479,15 @@ export const tailwindClasses = (part, attributes, manifest, ...custom) => {
|
|
|
508
479
|
|
|
509
480
|
let partName = 'base';
|
|
510
481
|
|
|
511
|
-
if (
|
|
512
|
-
part !== 'base' &&
|
|
513
|
-
part?.length > 0 &&
|
|
514
|
-
typeof manifest?.tailwind?.parts?.[part] !== 'undefined' &&
|
|
515
|
-
allParts.includes(part)
|
|
516
|
-
) {
|
|
482
|
+
if (part !== 'base' && part?.length > 0 && typeof manifest?.tailwind?.parts?.[part] !== 'undefined' && allParts.includes(part)) {
|
|
517
483
|
partName = part;
|
|
518
484
|
} else if (part !== 'base') {
|
|
519
485
|
throw new Error(`Part '${part}' is not defined in the manifest.`);
|
|
520
486
|
}
|
|
521
487
|
|
|
522
488
|
// Base classes.
|
|
523
|
-
const baseBaseClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditorOnly ??
|
|
524
|
-
|
|
525
|
-
manifest?.tailwind?.base?.twClassesEditorOnly ??
|
|
526
|
-
manifest?.tailwind?.base?.twClasses ?? [''];
|
|
527
|
-
const baseEditorClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditor ??
|
|
528
|
-
manifest?.tailwind?.base?.twClassesEditor ?? [''];
|
|
489
|
+
const baseBaseClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditorOnly ?? manifest?.tailwind?.parts?.[partName]?.twClasses ?? manifest?.tailwind?.base?.twClassesEditorOnly ?? manifest?.tailwind?.base?.twClasses ?? [''];
|
|
490
|
+
const baseEditorClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditor ?? manifest?.tailwind?.base?.twClassesEditor ?? [''];
|
|
529
491
|
|
|
530
492
|
// Option classes.
|
|
531
493
|
const options = manifest?.tailwind?.options ?? {};
|
|
@@ -549,12 +511,5 @@ export const tailwindClasses = (part, attributes, manifest, ...custom) => {
|
|
|
549
511
|
|
|
550
512
|
const partPrefix = manifest.title.replace(/[^a-zA-Z]+/g, '-').toLowerCase();
|
|
551
513
|
|
|
552
|
-
return clsx(
|
|
553
|
-
document.body.classList.contains('es-wp-debug') && `_es__${partPrefix}/${part}`,
|
|
554
|
-
unifyClasses(baseBaseClasses),
|
|
555
|
-
unifyClasses(baseEditorClasses),
|
|
556
|
-
...optionClasses,
|
|
557
|
-
...combinationClasses,
|
|
558
|
-
...custom,
|
|
559
|
-
);
|
|
514
|
+
return clsx(document.body.classList.contains('es-wp-debug') && `_es__${partPrefix}/${part}`, unifyClasses(baseBaseClasses), unifyClasses(baseEditorClasses), ...optionClasses, ...combinationClasses, ...custom);
|
|
560
515
|
};
|
package/scripts/helpers/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// All exports are sorted in alphabetical order.
|
|
2
2
|
|
|
3
|
-
export {
|
|
4
|
-
getBreakpointData,
|
|
5
|
-
getBreakpointNames,
|
|
6
|
-
getGlobalManifest,
|
|
7
|
-
getBreakpointUiData,
|
|
8
|
-
getResponsiveData,
|
|
9
|
-
} from './breakpoints';
|
|
3
|
+
export { getBreakpointData, getBreakpointNames, getGlobalManifest, getBreakpointUiData, getResponsiveData } from './breakpoints';
|
|
10
4
|
export { cookies } from './cookies';
|
|
11
5
|
export { dynamicImport } from './dynamic-import';
|
package/scripts/index.js
CHANGED
|
@@ -15,23 +15,10 @@ export * from './editor/fetch';
|
|
|
15
15
|
export * from './editor/options';
|
|
16
16
|
export * from './editor/utility';
|
|
17
17
|
export * from './editor/tailwindcss';
|
|
18
|
-
export {
|
|
19
|
-
getAttributes,
|
|
20
|
-
getExample,
|
|
21
|
-
getFullBlockName,
|
|
22
|
-
getFullBlockNameVariation,
|
|
23
|
-
registerBlocks,
|
|
24
|
-
registerVariations,
|
|
25
|
-
} from './editor/registration';
|
|
18
|
+
export { getAttributes, getExample, getFullBlockName, getFullBlockNameVariation, registerBlocks, registerVariations } from './editor/registration';
|
|
26
19
|
export { STORE_NAME, BUILD_VERSION, setStore, setStoreGlobalWindow, setConfigFlags } from './editor/store';
|
|
27
20
|
|
|
28
21
|
// Helpers.
|
|
29
|
-
export {
|
|
30
|
-
getBreakpointData,
|
|
31
|
-
getBreakpointNames,
|
|
32
|
-
getGlobalManifest,
|
|
33
|
-
getBreakpointUiData,
|
|
34
|
-
getResponsiveData,
|
|
35
|
-
} from './helpers/breakpoints';
|
|
22
|
+
export { getBreakpointData, getBreakpointNames, getGlobalManifest, getBreakpointUiData, getResponsiveData } from './helpers/breakpoints';
|
|
36
23
|
export { cookies } from './helpers/cookies';
|
|
37
24
|
export { dynamicImport } from './helpers/dynamic-import';
|
|
@@ -15,11 +15,7 @@ export const yoastSeo = (options) => {
|
|
|
15
15
|
|
|
16
16
|
domReady(() => {
|
|
17
17
|
// Ensure YoastSEO.js is present and can access the necessary features.
|
|
18
|
-
if (
|
|
19
|
-
typeof YoastSEO === 'undefined' ||
|
|
20
|
-
typeof YoastSEO.analysis === 'undefined' ||
|
|
21
|
-
typeof YoastSEO.analysis.worker === 'undefined'
|
|
22
|
-
) {
|
|
18
|
+
if (typeof YoastSEO === 'undefined' || typeof YoastSEO.analysis === 'undefined' || typeof YoastSEO.analysis.worker === 'undefined') {
|
|
23
19
|
return;
|
|
24
20
|
}
|
|
25
21
|
|
package/webpack/base.mjs
CHANGED
|
@@ -7,28 +7,17 @@ import webpack from 'webpack';
|
|
|
7
7
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
8
8
|
import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
|
|
9
9
|
import DependencyExtractionWebpackPlugin from '@wordpress/dependency-extraction-webpack-plugin';
|
|
10
|
+
import { esTwResponsiveCompiler } from './responsive-compiler.mjs';
|
|
10
11
|
|
|
11
12
|
export default (options) => {
|
|
12
13
|
// All Plugins used in production and development build.
|
|
13
14
|
const plugins = [];
|
|
14
15
|
|
|
15
|
-
// Provide global variables to window object.
|
|
16
|
-
if (!options.overrides.includes('providePlugin')) {
|
|
17
|
-
plugins.push(
|
|
18
|
-
new webpack.ProvidePlugin({
|
|
19
|
-
$: 'jquery',
|
|
20
|
-
jQuery: 'jquery',
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
16
|
// Provide variables to code build.
|
|
26
17
|
if (!options.overrides.includes('definePlugin')) {
|
|
27
18
|
plugins.push(
|
|
28
19
|
new webpack.DefinePlugin({
|
|
29
|
-
'process.env.VERSION': JSON.stringify(
|
|
30
|
-
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
|
|
31
|
-
),
|
|
20
|
+
'process.env.VERSION': JSON.stringify(Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)),
|
|
32
21
|
'process.browser': true,
|
|
33
22
|
}),
|
|
34
23
|
);
|
|
@@ -57,6 +46,16 @@ export default (options) => {
|
|
|
57
46
|
);
|
|
58
47
|
}
|
|
59
48
|
|
|
49
|
+
// Generate Tailwind manifest class sources before every build.
|
|
50
|
+
if (!options.overrides.includes('responsiveCompiler')) {
|
|
51
|
+
plugins.push(
|
|
52
|
+
esTwResponsiveCompiler({
|
|
53
|
+
projectDir: options.config.absolutePath,
|
|
54
|
+
breakpoints: options.tailwindBreakpoints,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
60
59
|
// All module used in production and development build.
|
|
61
60
|
const module = {
|
|
62
61
|
rules: [],
|
|
@@ -88,26 +87,14 @@ export default (options) => {
|
|
|
88
87
|
module.rules.push({
|
|
89
88
|
test: /\.css$/,
|
|
90
89
|
exclude: /node_modules/,
|
|
91
|
-
use: [
|
|
92
|
-
MiniCssExtractPlugin.loader,
|
|
93
|
-
{
|
|
94
|
-
loader: 'css-loader',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
loader: 'postcss-loader',
|
|
98
|
-
},
|
|
99
|
-
],
|
|
90
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader', '@tailwindcss/webpack'],
|
|
100
91
|
});
|
|
101
92
|
|
|
102
93
|
// Node modules - CSS.
|
|
103
94
|
module.rules.push({
|
|
104
95
|
test: /\.css$/,
|
|
105
96
|
include: /node_modules/,
|
|
106
|
-
use: [
|
|
107
|
-
{
|
|
108
|
-
loader: 'css-loader',
|
|
109
|
-
},
|
|
110
|
-
],
|
|
97
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
|
111
98
|
});
|
|
112
99
|
|
|
113
100
|
// Node modules - Eightshift package fonts.
|
package/webpack/helpers.mjs
CHANGED
|
@@ -15,23 +15,13 @@ import path from 'path';
|
|
|
15
15
|
* @param {string} blocksManifestSettingsPath Main global settings manifest.json path after projectPath location.
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
function getConfig(
|
|
19
|
-
projectDir,
|
|
20
|
-
projectPathConfig,
|
|
21
|
-
blocksAssetsPathConfig = 'src/Blocks/assets',
|
|
22
|
-
outputPathConfig = 'public',
|
|
23
|
-
blocksManifestSettingsPath = 'src/Blocks/manifest.json',
|
|
24
|
-
) {
|
|
18
|
+
function getConfig(projectDir, projectPathConfig, blocksAssetsPathConfig = 'src/Blocks/assets', outputPathConfig = 'public', blocksManifestSettingsPath = 'src/Blocks/manifest.json') {
|
|
25
19
|
if (typeof projectDir === 'undefined') {
|
|
26
|
-
throw Error(
|
|
27
|
-
'projectDir parameter is empty, please provide. This key represents: Current project directory absolute path. For example: __dirname',
|
|
28
|
-
);
|
|
20
|
+
throw Error('projectDir parameter is empty, please provide. This key represents: Current project directory absolute path. For example: __dirname');
|
|
29
21
|
}
|
|
30
22
|
|
|
31
23
|
if (typeof projectPathConfig === 'undefined') {
|
|
32
|
-
throw Error(
|
|
33
|
-
'projectPath parameter is empty, please provide. This key represents: Project path relative to project root. For example: wp-content/themes/eightshift-boilerplate',
|
|
34
|
-
);
|
|
24
|
+
throw Error('projectPath parameter is empty, please provide. This key represents: Project path relative to project root. For example: wp-content/themes/eightshift-boilerplate');
|
|
35
25
|
}
|
|
36
26
|
|
|
37
27
|
// Clear all slashes from user config.
|
|
@@ -55,16 +45,8 @@ function getConfig(
|
|
|
55
45
|
// Source files entries absolute locations.
|
|
56
46
|
applicationAdminEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-admin.js'),
|
|
57
47
|
applicationBlocksEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks.js'),
|
|
58
|
-
applicationBlocksEditorEntry: path.resolve(
|
|
59
|
-
|
|
60
|
-
blocksAssetsPathConfigClean,
|
|
61
|
-
'application-blocks-editor.js',
|
|
62
|
-
),
|
|
63
|
-
applicationBlocksFrontendEntry: path.resolve(
|
|
64
|
-
absolutePath,
|
|
65
|
-
blocksAssetsPathConfigClean,
|
|
66
|
-
'application-blocks-frontend.js',
|
|
67
|
-
),
|
|
48
|
+
applicationBlocksEditorEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks-editor.js'),
|
|
49
|
+
applicationBlocksFrontendEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks-frontend.js'),
|
|
68
50
|
|
|
69
51
|
blocksManifestSettingsPath: path.resolve(absolutePath, blocksManifestSettingsPathClean),
|
|
70
52
|
};
|
package/webpack/index.mjs
CHANGED
|
@@ -14,17 +14,12 @@ const eightshiftConfig = (mode, optionsData = {}) => {
|
|
|
14
14
|
const options = {
|
|
15
15
|
config: {},
|
|
16
16
|
overrides: [],
|
|
17
|
+
tailwindBreakpoints: ['sm', 'md'],
|
|
17
18
|
...optionsData,
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
// Append project config using getConfig helper.
|
|
21
|
-
options.config = getConfig(
|
|
22
|
-
optionsData.config.projectDir,
|
|
23
|
-
optionsData.config.projectPath,
|
|
24
|
-
optionsData.config.blocksAssetsPath,
|
|
25
|
-
optionsData.config.outputPath,
|
|
26
|
-
optionsData.config.blocksManifestSettingsPath,
|
|
27
|
-
);
|
|
22
|
+
options.config = getConfig(optionsData.config.projectDir, optionsData.config.projectPath, optionsData.config.blocksAssetsPath, optionsData.config.outputPath, optionsData.config.blocksManifestSettingsPath);
|
|
28
23
|
|
|
29
24
|
options.config.mode = mode;
|
|
30
25
|
options.config.filesOutput = mode === 'production' ? '[name]-[contenthash]' : '[name]';
|
package/webpack/project.mjs
CHANGED
|
@@ -29,18 +29,12 @@ export default (options) => {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Load ApplicationBlocksEditor Entrypoint.
|
|
32
|
-
if (
|
|
33
|
-
!options.overrides.includes('applicationBlocksEditor') &&
|
|
34
|
-
fs.existsSync(options.config.applicationBlocksEditorEntry)
|
|
35
|
-
) {
|
|
32
|
+
if (!options.overrides.includes('applicationBlocksEditor') && fs.existsSync(options.config.applicationBlocksEditorEntry)) {
|
|
36
33
|
entry.applicationBlocksEditor = options.config.applicationBlocksEditorEntry;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
// Load applicationBlocksFrontend Entrypoint.
|
|
40
|
-
if (
|
|
41
|
-
!options.overrides.includes('applicationBlocksFrontend') &&
|
|
42
|
-
fs.existsSync(options.config.applicationBlocksFrontendEntry)
|
|
43
|
-
) {
|
|
37
|
+
if (!options.overrides.includes('applicationBlocksFrontend') && fs.existsSync(options.config.applicationBlocksFrontendEntry)) {
|
|
44
38
|
entry.applicationBlocksFrontend = options.config.applicationBlocksFrontendEntry;
|
|
45
39
|
}
|
|
46
40
|
|