@eightshift/frontend-libs-tailwind 3.1.2 → 3.2.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/CHANGELOG.md +16 -0
- package/bun.lock +66 -8
- package/package.json +3 -3
- package/webpack/base.mjs +13 -24
- package/webpack/index.mjs +1 -0
- package/webpack/responsive-compiler.mjs +171 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -22,11 +22,12 @@ jobs:
|
|
|
22
22
|
strategy:
|
|
23
23
|
fail-fast: false
|
|
24
24
|
matrix:
|
|
25
|
-
node: [
|
|
25
|
+
node: ['latest']
|
|
26
26
|
steps:
|
|
27
27
|
- name: Lint assets
|
|
28
28
|
uses: infinum/eightshift-deploy-actions-public/.github/actions/lint/assets@main
|
|
29
29
|
with:
|
|
30
30
|
NODE_VERSION: ${{ matrix.node }}
|
|
31
|
-
PROJECT_PATH: '
|
|
32
|
-
|
|
31
|
+
PROJECT_PATH: '.'
|
|
32
|
+
USE_BUILD: false
|
|
33
|
+
USE_LINT_STYLE: false
|
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,21 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [3.2.0]
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Built-in Tailwind responsive class compiler: scans every `manifest.json`, extracts classes from `twClasses`, `twClassesEditor` and `twClassesEditorOnly`, expands `responsive: true` blocks across all configured breakpoints, and writes `es-tw-frontend-classes.txt` and `es-tw-editor-classes.txt` at the project root. Runs before each build and on manifest changes in watch mode.
|
|
14
|
+
- New `tailwindBreakpoints` option on `eightshiftConfig` (defaults to `['sm', 'md']`).
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **Breaking:** default CSS rule now uses `@tailwindcss/webpack` instead of `postcss-loader`. Projects that previously set `overrides: ['css']` and re-declared their own CSS rule and `esTwResponsiveCompiler` plugin should remove that boilerplate and rely on the libs defaults.
|
|
19
|
+
|
|
20
|
+
### Removed
|
|
21
|
+
|
|
22
|
+
- `postcss` and `postcss-loader` dependencies.
|
|
23
|
+
|
|
9
24
|
## [3.1.2]
|
|
10
25
|
|
|
11
26
|
### Fixed
|
|
@@ -331,6 +346,7 @@ Co-authored with @piqusy
|
|
|
331
346
|
- Initial release.
|
|
332
347
|
|
|
333
348
|
[Unreleased]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/master...HEAD
|
|
349
|
+
[3.2.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/3.1.2...3.2.0
|
|
334
350
|
[3.1.2]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/3.1.1...3.1.2
|
|
335
351
|
[3.1.1]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/3.1.0...3.1.1
|
|
336
352
|
[3.1.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/3.0.0...3.1.0
|
package/bun.lock
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
9
9
|
"@stylistic/stylelint-plugin": "^5.1.0",
|
|
10
10
|
"@swc/core": "^1.15.30",
|
|
11
|
+
"@tailwindcss/webpack": "^4.2.4",
|
|
11
12
|
"@wordpress/dependency-extraction-webpack-plugin": "^6.44.0",
|
|
12
13
|
"browserslist": "^4.28.2",
|
|
13
14
|
"css-loader": "^7.1.4",
|
|
@@ -18,12 +19,11 @@
|
|
|
18
19
|
"eslint-plugin-react": "^7.37.5",
|
|
19
20
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
20
21
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
22
|
+
"glob": "^13.0.6",
|
|
21
23
|
"globals": "^17.5.0",
|
|
22
24
|
"husky": "^9.1.7",
|
|
23
25
|
"lightningcss": "^1.32.0",
|
|
24
26
|
"mini-css-extract-plugin": "^2.10.2",
|
|
25
|
-
"postcss": "^8.5.10",
|
|
26
|
-
"postcss-loader": "^8.2.1",
|
|
27
27
|
"prettier": "^3.8.3",
|
|
28
28
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
29
29
|
"sonner": "^2.0.7",
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
"packages": {
|
|
49
|
+
"@alloc/quick-lru": ["@alloc/quick-lru@5.2.0", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
|
|
50
|
+
|
|
49
51
|
"@babel/code-frame": ["@babel/code-frame@7.27.1", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.27.1", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg=="],
|
|
50
52
|
|
|
51
53
|
"@babel/compat-data": ["@babel/compat-data@7.28.5", "", {}, "sha512-6uFXyCayocRbqhZOB+6XcuZbkMNimwfVGFji8CTZnCzOHVGvDqzvitu1re2AU5LROliz7eQPhB8CpAMvnx9EjA=="],
|
|
@@ -198,6 +200,36 @@
|
|
|
198
200
|
|
|
199
201
|
"@swc/types": ["@swc/types@0.1.26", "", { "dependencies": { "@swc/counter": "^0.1.3" } }, "sha512-lyMwd7WGgG79RS7EERZV3T8wMdmPq3xwyg+1nmAM64kIhx5yl+juO2PYIHb7vTiPgPCj8LYjsNV2T5wiQHUEaw=="],
|
|
200
202
|
|
|
203
|
+
"@tailwindcss/node": ["@tailwindcss/node@4.3.0", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "enhanced-resolve": "^5.21.0", "jiti": "^2.6.1", "lightningcss": "1.32.0", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.3.0" } }, "sha512-aFb4gUhFOgdh9AXo4IzBEOzBkkAxm9VigwDJnMIYv3lcfXCJVesNfbEaBl4BNgVRyid92AmdviqwBUBRKSeY3g=="],
|
|
204
|
+
|
|
205
|
+
"@tailwindcss/oxide": ["@tailwindcss/oxide@4.3.0", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.3.0", "@tailwindcss/oxide-darwin-arm64": "4.3.0", "@tailwindcss/oxide-darwin-x64": "4.3.0", "@tailwindcss/oxide-freebsd-x64": "4.3.0", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.0", "@tailwindcss/oxide-linux-arm64-gnu": "4.3.0", "@tailwindcss/oxide-linux-arm64-musl": "4.3.0", "@tailwindcss/oxide-linux-x64-gnu": "4.3.0", "@tailwindcss/oxide-linux-x64-musl": "4.3.0", "@tailwindcss/oxide-wasm32-wasi": "4.3.0", "@tailwindcss/oxide-win32-arm64-msvc": "4.3.0", "@tailwindcss/oxide-win32-x64-msvc": "4.3.0" } }, "sha512-F7HZGBeN9I0/AuuJS5PwcD8xayx5ri5GhjYUDBEVYUkexyA/giwbDNjRVrxSezE3T250OU2K/wp/ltWx3UOefg=="],
|
|
206
|
+
|
|
207
|
+
"@tailwindcss/oxide-android-arm64": ["@tailwindcss/oxide-android-arm64@4.3.0", "", { "os": "android", "cpu": "arm64" }, "sha512-TJPiq67tKlLuObP6RkwvVGDoxCMBVtDgKkLfa/uyj7/FyxvQwHS+UOnVrXXgbEsfUaMgiVvC4KbJnRr26ho4Ng=="],
|
|
208
|
+
|
|
209
|
+
"@tailwindcss/oxide-darwin-arm64": ["@tailwindcss/oxide-darwin-arm64@4.3.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-oMN/WZRb+SO37BmUElEgeEWuU8E/HXRkiODxJxLe1UTHVXLrdVSgfaJV7pSlhRGMSOiXLuxTIjfsF3wYvz8cgQ=="],
|
|
210
|
+
|
|
211
|
+
"@tailwindcss/oxide-darwin-x64": ["@tailwindcss/oxide-darwin-x64@4.3.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-N6CUmu4a6bKVADfw77p+iw6Yd9Q3OBhe0veaDX+QazfuVYlQsHfDgxBrsjQ/IW+zywL8mTrNd0SdJT/zgtvMdA=="],
|
|
212
|
+
|
|
213
|
+
"@tailwindcss/oxide-freebsd-x64": ["@tailwindcss/oxide-freebsd-x64@4.3.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-zDL5hBkQdH5C6MpqbK3gQAgP80tsMwSI26vjOzjJtNCMUo0lFgOItzHKBIupOZNQxt3ouPH7RPhvNhiTfCe5CQ=="],
|
|
214
|
+
|
|
215
|
+
"@tailwindcss/oxide-linux-arm-gnueabihf": ["@tailwindcss/oxide-linux-arm-gnueabihf@4.3.0", "", { "os": "linux", "cpu": "arm" }, "sha512-R06HdNi7A7OEoMsf6d4tjZ71RCWnZQPHj2mnotSFURjNLdBC+cIgXQ7l81CqeoiQftjf6OOblxXMInMgN2VzMA=="],
|
|
216
|
+
|
|
217
|
+
"@tailwindcss/oxide-linux-arm64-gnu": ["@tailwindcss/oxide-linux-arm64-gnu@4.3.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-qTJHELX8jetjhRQHCLilkVLmybpzNQAtaI/gaoVoidn/ufbNDbAo8KlK2J+yPoc8wQxvDxCmh/5lr8nC1+lTbg=="],
|
|
218
|
+
|
|
219
|
+
"@tailwindcss/oxide-linux-arm64-musl": ["@tailwindcss/oxide-linux-arm64-musl@4.3.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-Z6sukiQsngnWO+l39X4pPbiWT81IC+PLKF+PHxIlyZbGNb9MODfYlXEVlFvej5BOZInWX01kVyzeLvHsXhfczQ=="],
|
|
220
|
+
|
|
221
|
+
"@tailwindcss/oxide-linux-x64-gnu": ["@tailwindcss/oxide-linux-x64-gnu@4.3.0", "", { "os": "linux", "cpu": "x64" }, "sha512-DRNdQRpSGzRGfARVuVkxvM8Q12nh19l4BF/G7zGA1oe+9wcC6saFBHTISrpIcKzhiXtSrlSrluCfvMuledoCTQ=="],
|
|
222
|
+
|
|
223
|
+
"@tailwindcss/oxide-linux-x64-musl": ["@tailwindcss/oxide-linux-x64-musl@4.3.0", "", { "os": "linux", "cpu": "x64" }, "sha512-Z0IADbDo8bh6I7h2IQMx601AdXBLfFpEdUotft86evd/8ZPflZe9COPO8Q1vw+pfLWIUo9zN/JGZvwuAJqduqg=="],
|
|
224
|
+
|
|
225
|
+
"@tailwindcss/oxide-wasm32-wasi": ["@tailwindcss/oxide-wasm32-wasi@4.3.0", "", { "dependencies": { "@emnapi/core": "^1.10.0", "@emnapi/runtime": "^1.10.0", "@emnapi/wasi-threads": "^1.2.1", "@napi-rs/wasm-runtime": "^1.1.4", "@tybys/wasm-util": "^0.10.1", "tslib": "^2.8.1" }, "cpu": "none" }, "sha512-HNZGOUxEmElksYR7S6sC5jTeNGpobAsy9u7Gu0AskJ8/20FR9GqebUyB+HBcU/ax6BHuiuJi+Oda4B+YX6H1yA=="],
|
|
226
|
+
|
|
227
|
+
"@tailwindcss/oxide-win32-arm64-msvc": ["@tailwindcss/oxide-win32-arm64-msvc@4.3.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-Pe+RPVTi1T+qymuuRpcdvwSVZjnll/f7n8gBxMMh3xLTctMDKqpdfGimbMyioqtLhUYZxdJ9wGNhV7MKHvgZsQ=="],
|
|
228
|
+
|
|
229
|
+
"@tailwindcss/oxide-win32-x64-msvc": ["@tailwindcss/oxide-win32-x64-msvc@4.3.0", "", { "os": "win32", "cpu": "x64" }, "sha512-Mvrf2kXW/yeW/OTezZlCGOirXRcUuLIBx/5Y12BaPM7wJoryG6dfS/NJL8aBPqtTEx/Vm4T4vKzFUcKDT+TKUA=="],
|
|
230
|
+
|
|
231
|
+
"@tailwindcss/webpack": ["@tailwindcss/webpack@4.3.0", "", { "dependencies": { "@alloc/quick-lru": "^5.2.0", "@tailwindcss/node": "4.3.0", "@tailwindcss/oxide": "4.3.0", "tailwindcss": "4.3.0" }, "peerDependencies": { "webpack": "^5" } }, "sha512-oaEdJ/X298hmdZrvI1NmAQZFKJ5XJiRXxHwlAw62GOaB5G7Ic3Uv+gfomdI8aukJXRH87h5nERy8yxvAqwqMnQ=="],
|
|
232
|
+
|
|
201
233
|
"@tannin/compile": ["@tannin/compile@1.1.0", "", { "dependencies": { "@tannin/evaluate": "^1.2.0", "@tannin/postfix": "^1.1.0" } }, "sha512-n8m9eNDfoNZoxdvWiTfW/hSPhehzLJ3zW7f8E7oT6mCROoMNWCB4TYtv041+2FMAxweiE0j7i1jubQU4MEC/Gg=="],
|
|
202
234
|
|
|
203
235
|
"@tannin/evaluate": ["@tannin/evaluate@1.2.0", "", {}, "sha512-3ioXvNowbO/wSrxsDG5DKIMxC81P0QrQTYai8zFNY+umuoHWRPbQ/TuuDEOju9E+jQDXmj6yI5GyejNuh8I+eg=="],
|
|
@@ -374,7 +406,7 @@
|
|
|
374
406
|
|
|
375
407
|
"convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="],
|
|
376
408
|
|
|
377
|
-
"cosmiconfig": ["cosmiconfig@9.0.
|
|
409
|
+
"cosmiconfig": ["cosmiconfig@9.0.1", "", { "dependencies": { "env-paths": "^2.2.1", "import-fresh": "^3.3.0", "js-yaml": "^4.1.0", "parse-json": "^5.2.0" }, "peerDependencies": { "typescript": ">=4.9.5" }, "optionalPeers": ["typescript"] }, "sha512-hr4ihw+DBqcvrsEDioRO31Z17x71pUYoNe/4h6Z0wB72p7MU7/9gH8Q3s12NFhHPfYBBOV3qyfUxmr/Yn3shnQ=="],
|
|
378
410
|
|
|
379
411
|
"cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
|
380
412
|
|
|
@@ -552,6 +584,8 @@
|
|
|
552
584
|
|
|
553
585
|
"gettext-parser": ["gettext-parser@1.4.0", "", { "dependencies": { "encoding": "^0.1.12", "safe-buffer": "^5.1.1" } }, "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA=="],
|
|
554
586
|
|
|
587
|
+
"glob": ["glob@13.0.6", "", { "dependencies": { "minimatch": "^10.2.2", "minipass": "^7.1.3", "path-scurry": "^2.0.2" } }, "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw=="],
|
|
588
|
+
|
|
555
589
|
"glob-parent": ["glob-parent@6.0.2", "", { "dependencies": { "is-glob": "^4.0.3" } }, "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A=="],
|
|
556
590
|
|
|
557
591
|
"glob-to-regexp": ["glob-to-regexp@0.4.1", "", {}, "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw=="],
|
|
@@ -764,7 +798,9 @@
|
|
|
764
798
|
|
|
765
799
|
"loose-envify": ["loose-envify@1.4.0", "", { "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, "bin": { "loose-envify": "cli.js" } }, "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q=="],
|
|
766
800
|
|
|
767
|
-
"lru-cache": ["lru-cache@
|
|
801
|
+
"lru-cache": ["lru-cache@11.3.6", "", {}, "sha512-Gf/KoL3C/MlI7Bt0PGI9I+TeTC/I6r/csU58N4BSNc4lppLBeKsOdFYkK+dX0ABDUMJNfCHTyPpzwwO21Awd3A=="],
|
|
802
|
+
|
|
803
|
+
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
|
|
768
804
|
|
|
769
805
|
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
|
|
770
806
|
|
|
@@ -790,6 +826,8 @@
|
|
|
790
826
|
|
|
791
827
|
"minimatch": ["minimatch@10.2.4", "", { "dependencies": { "brace-expansion": "^5.0.2" } }, "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg=="],
|
|
792
828
|
|
|
829
|
+
"minipass": ["minipass@7.1.3", "", {}, "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A=="],
|
|
830
|
+
|
|
793
831
|
"motion": ["motion@12.38.0", "", { "dependencies": { "framer-motion": "^12.38.0", "tslib": "^2.4.0" }, "peerDependencies": { "@emotion/is-prop-valid": "*", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["@emotion/is-prop-valid", "react", "react-dom"] }, "sha512-uYfXzeHlgThchzwz5Te47dlv5JOUC7OB4rjJ/7XTUgtBZD8CchMN8qEJ4ZVsUmTyYA44zjV0fBwsiktRuFnn+w=="],
|
|
794
832
|
|
|
795
833
|
"motion-dom": ["motion-dom@12.38.0", "", { "dependencies": { "motion-utils": "^12.36.0" } }, "sha512-pdkHLD8QYRp8VfiNLb8xIBJis1byQ9gPT3Jnh2jqfFtAsWUA3dEepDlsWe/xMpO8McV+VdpKVcp+E+TGJEtOoA=="],
|
|
@@ -846,6 +884,8 @@
|
|
|
846
884
|
|
|
847
885
|
"path-parse": ["path-parse@1.0.7", "", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="],
|
|
848
886
|
|
|
887
|
+
"path-scurry": ["path-scurry@2.0.2", "", { "dependencies": { "lru-cache": "^11.0.0", "minipass": "^7.1.2" } }, "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg=="],
|
|
888
|
+
|
|
849
889
|
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
|
850
890
|
|
|
851
891
|
"picomatch": ["picomatch@4.0.3", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
|
|
@@ -870,8 +910,6 @@
|
|
|
870
910
|
|
|
871
911
|
"postcss-discard-overridden": ["postcss-discard-overridden@7.0.0", "", { "peerDependencies": { "postcss": "^8.4.31" } }, "sha512-GmNAzx88u3k2+sBTZrJSDauR0ccpE24omTQCVmaTTZFz1du6AasspjaUPMJ2ud4RslZpoFKyf+6MSPETLojc6w=="],
|
|
872
912
|
|
|
873
|
-
"postcss-loader": ["postcss-loader@8.2.1", "", { "dependencies": { "cosmiconfig": "^9.0.0", "jiti": "^2.5.1", "semver": "^7.6.2" }, "peerDependencies": { "@rspack/core": "0.x || ^1.0.0 || ^2.0.0-0", "postcss": "^7.0.0 || ^8.0.1", "webpack": "^5.0.0" }, "optionalPeers": ["@rspack/core", "webpack"] }, "sha512-k98jtRzthjj3f76MYTs9JTpRqV1RaaMhEU0Lpw9OTmQZQdppg4B30VZ74BojuBHt3F4KyubHJoXCMUeM8Bqeow=="],
|
|
874
|
-
|
|
875
913
|
"postcss-merge-longhand": ["postcss-merge-longhand@7.0.4", "", { "dependencies": { "postcss-value-parser": "^4.2.0", "stylehacks": "^7.0.4" }, "peerDependencies": { "postcss": "^8.4.31" } }, "sha512-zer1KoZA54Q8RVHKOY5vMke0cCdNxMP3KBfDerjH/BYHh4nCIh+1Yy0t1pAEQF18ac/4z3OFclO+ZVH8azjR4A=="],
|
|
876
914
|
|
|
877
915
|
"postcss-merge-rules": ["postcss-merge-rules@7.0.4", "", { "dependencies": { "browserslist": "^4.23.3", "caniuse-api": "^3.0.0", "cssnano-utils": "^5.0.0", "postcss-selector-parser": "^6.1.2" }, "peerDependencies": { "postcss": "^8.4.31" } }, "sha512-ZsaamiMVu7uBYsIdGtKJ64PkcQt6Pcpep/uO90EpLS3dxJi6OXamIobTYcImyXGoW0Wpugh7DSD3XzxZS9JCPg=="],
|
|
@@ -1068,6 +1106,8 @@
|
|
|
1068
1106
|
|
|
1069
1107
|
"table": ["table@6.9.0", "", { "dependencies": { "ajv": "^8.0.1", "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", "string-width": "^4.2.3", "strip-ansi": "^6.0.1" } }, "sha512-9kY+CygyYM6j02t5YFHbNz2FN5QmYGv9zAjVp4lCDjlCw7amdckXlEt/bjMhUIfj4ThGRE4gCUH5+yGnNuPo5A=="],
|
|
1070
1108
|
|
|
1109
|
+
"tailwindcss": ["tailwindcss@4.3.0", "", {}, "sha512-y6nxMGB1nMW9R6k96e5gdIFzcfL/gTJRNaqGes1YvkLnPVXzWgbqFF2yLC0T8G774n24cx3Pe8XrKoniCOAH+Q=="],
|
|
1110
|
+
|
|
1071
1111
|
"tannin": ["tannin@1.2.0", "", { "dependencies": { "@tannin/plural-forms": "^1.1.0" } }, "sha512-U7GgX/RcSeUETbV7gYgoz8PD7Ni4y95pgIP/Z6ayI3CfhSujwKEBlGFTCRN+Aqnuyf4AN2yHL+L8x+TCGjb9uA=="],
|
|
1072
1112
|
|
|
1073
1113
|
"tapable": ["tapable@2.3.0", "", {}, "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg=="],
|
|
@@ -1148,6 +1188,8 @@
|
|
|
1148
1188
|
|
|
1149
1189
|
"@babel/helper-compilation-targets/browserslist": ["browserslist@4.28.1", "", { "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", "electron-to-chromium": "^1.5.263", "node-releases": "^2.0.27", "update-browserslist-db": "^1.2.0" }, "bin": { "browserslist": "cli.js" } }, "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA=="],
|
|
1150
1190
|
|
|
1191
|
+
"@babel/helper-compilation-targets/lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
|
1192
|
+
|
|
1151
1193
|
"@babel/helper-compilation-targets/semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
|
1152
1194
|
|
|
1153
1195
|
"@cacheable/memory/keyv": ["keyv@5.6.0", "", { "dependencies": { "@keyv/serialize": "^1.1.1" } }, "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw=="],
|
|
@@ -1164,6 +1206,20 @@
|
|
|
1164
1206
|
|
|
1165
1207
|
"@keyv/bigmap/keyv": ["keyv@5.6.0", "", { "dependencies": { "@keyv/serialize": "^1.1.1" } }, "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw=="],
|
|
1166
1208
|
|
|
1209
|
+
"@tailwindcss/node/enhanced-resolve": ["enhanced-resolve@5.21.2", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.3" } }, "sha512-xe9vQb5kReirPUxgQrXA3ihgbCqssmTiM7cOZ+Gzu+VeGWgpV98lLZvp0dl4yriyAePcewxGUs9UpKD8PET9KQ=="],
|
|
1210
|
+
|
|
1211
|
+
"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.10.0", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.1", "tslib": "^2.4.0" }, "bundled": true }, "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw=="],
|
|
1212
|
+
|
|
1213
|
+
"@tailwindcss/oxide-wasm32-wasi/@emnapi/runtime": ["@emnapi/runtime@1.10.0", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA=="],
|
|
1214
|
+
|
|
1215
|
+
"@tailwindcss/oxide-wasm32-wasi/@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.2.1", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w=="],
|
|
1216
|
+
|
|
1217
|
+
"@tailwindcss/oxide-wasm32-wasi/@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.4", "", { "dependencies": { "@tybys/wasm-util": "^0.10.1" }, "peerDependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1" }, "bundled": true }, "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow=="],
|
|
1218
|
+
|
|
1219
|
+
"@tailwindcss/oxide-wasm32-wasi/@tybys/wasm-util": ["@tybys/wasm-util@0.10.2", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg=="],
|
|
1220
|
+
|
|
1221
|
+
"@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
|
1222
|
+
|
|
1167
1223
|
"@types/eslint/@types/estree": ["@types/estree@1.0.7", "", {}, "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ=="],
|
|
1168
1224
|
|
|
1169
1225
|
"@types/eslint-scope/@types/estree": ["@types/estree@1.0.7", "", {}, "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ=="],
|
|
@@ -1216,6 +1272,8 @@
|
|
|
1216
1272
|
|
|
1217
1273
|
"log-update/strip-ansi": ["strip-ansi@7.1.0", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ=="],
|
|
1218
1274
|
|
|
1275
|
+
"magic-string/@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="],
|
|
1276
|
+
|
|
1219
1277
|
"micromatch/picomatch": ["picomatch@2.3.2", "", {}, "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA=="],
|
|
1220
1278
|
|
|
1221
1279
|
"parse-json/@babel/code-frame": ["@babel/code-frame@7.26.2", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.25.9", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" } }, "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ=="],
|
|
@@ -1262,8 +1320,6 @@
|
|
|
1262
1320
|
|
|
1263
1321
|
"stylehacks/postcss-selector-parser": ["postcss-selector-parser@6.1.2", "", { "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" } }, "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg=="],
|
|
1264
1322
|
|
|
1265
|
-
"stylelint/cosmiconfig": ["cosmiconfig@9.0.1", "", { "dependencies": { "env-paths": "^2.2.1", "import-fresh": "^3.3.0", "js-yaml": "^4.1.0", "parse-json": "^5.2.0" }, "peerDependencies": { "typescript": ">=4.9.5" }, "optionalPeers": ["typescript"] }, "sha512-hr4ihw+DBqcvrsEDioRO31Z17x71pUYoNe/4h6Z0wB72p7MU7/9gH8Q3s12NFhHPfYBBOV3qyfUxmr/Yn3shnQ=="],
|
|
1266
|
-
|
|
1267
1323
|
"stylelint/file-entry-cache": ["file-entry-cache@11.1.2", "", { "dependencies": { "flat-cache": "^6.1.20" } }, "sha512-N2WFfK12gmrK1c1GXOqiAJ1tc5YE+R53zvQ+t5P8S5XhnmKYVB5eZEiLNZKDSmoG8wqqbF9EXYBBW/nef19log=="],
|
|
1268
1324
|
|
|
1269
1325
|
"stylelint/ignore": ["ignore@7.0.5", "", {}, "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg=="],
|
|
@@ -1306,6 +1362,8 @@
|
|
|
1306
1362
|
|
|
1307
1363
|
"@babel/helper-compilation-targets/browserslist/update-browserslist-db": ["update-browserslist-db@1.2.2", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-E85pfNzMQ9jpKkA7+TJAi4TJN+tBCuWh5rUcS/sv6cFi+1q9LYDwDI5dpUL0u/73EElyQ8d3TEaeW4sPedBqYA=="],
|
|
1308
1364
|
|
|
1365
|
+
"@tailwindcss/node/enhanced-resolve/tapable": ["tapable@2.3.3", "", {}, "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A=="],
|
|
1366
|
+
|
|
1309
1367
|
"ajv-formats/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
|
1310
1368
|
|
|
1311
1369
|
"ajv-keywords/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eightshift/frontend-libs-tailwind",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "A framework for creating modern Gutenberg themes with styling provided by Tailwind CSS.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Eightshift team",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
37
37
|
"@stylistic/stylelint-plugin": "^5.1.0",
|
|
38
38
|
"@swc/core": "^1.15.30",
|
|
39
|
+
"@tailwindcss/webpack": "^4.2.4",
|
|
39
40
|
"@wordpress/dependency-extraction-webpack-plugin": "^6.44.0",
|
|
40
41
|
"browserslist": "^4.28.2",
|
|
41
42
|
"css-loader": "^7.1.4",
|
|
@@ -46,12 +47,11 @@
|
|
|
46
47
|
"eslint-plugin-react": "^7.37.5",
|
|
47
48
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
48
49
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
50
|
+
"glob": "^13.0.6",
|
|
49
51
|
"globals": "^17.5.0",
|
|
50
52
|
"husky": "^9.1.7",
|
|
51
53
|
"lightningcss": "^1.32.0",
|
|
52
54
|
"mini-css-extract-plugin": "^2.10.2",
|
|
53
|
-
"postcss": "^8.5.10",
|
|
54
|
-
"postcss-loader": "^8.2.1",
|
|
55
55
|
"prettier": "^3.8.3",
|
|
56
56
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
57
57
|
"sonner": "^2.0.7",
|
package/webpack/base.mjs
CHANGED
|
@@ -7,21 +7,12 @@ 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(
|
|
@@ -57,6 +48,16 @@ export default (options) => {
|
|
|
57
48
|
);
|
|
58
49
|
}
|
|
59
50
|
|
|
51
|
+
// Generate Tailwind manifest class sources before every build.
|
|
52
|
+
if (!options.overrides.includes('responsiveCompiler')) {
|
|
53
|
+
plugins.push(
|
|
54
|
+
esTwResponsiveCompiler({
|
|
55
|
+
projectDir: options.config.absolutePath,
|
|
56
|
+
breakpoints: options.tailwindBreakpoints,
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
60
61
|
// All module used in production and development build.
|
|
61
62
|
const module = {
|
|
62
63
|
rules: [],
|
|
@@ -88,26 +89,14 @@ export default (options) => {
|
|
|
88
89
|
module.rules.push({
|
|
89
90
|
test: /\.css$/,
|
|
90
91
|
exclude: /node_modules/,
|
|
91
|
-
use: [
|
|
92
|
-
MiniCssExtractPlugin.loader,
|
|
93
|
-
{
|
|
94
|
-
loader: 'css-loader',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
loader: 'postcss-loader',
|
|
98
|
-
},
|
|
99
|
-
],
|
|
92
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader', '@tailwindcss/webpack'],
|
|
100
93
|
});
|
|
101
94
|
|
|
102
95
|
// Node modules - CSS.
|
|
103
96
|
module.rules.push({
|
|
104
97
|
test: /\.css$/,
|
|
105
98
|
include: /node_modules/,
|
|
106
|
-
use: [
|
|
107
|
-
{
|
|
108
|
-
loader: 'css-loader',
|
|
109
|
-
},
|
|
110
|
-
],
|
|
99
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
|
111
100
|
});
|
|
112
101
|
|
|
113
102
|
// Node modules - Eightshift package fonts.
|
package/webpack/index.mjs
CHANGED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack plugin that scans all `manifest.json` files inside a project and
|
|
3
|
+
* emits two class lists (`es-tw-frontend-classes.txt`, `es-tw-editor-classes.txt`)
|
|
4
|
+
* that Tailwind v4 can pick up via `@source`.
|
|
5
|
+
*
|
|
6
|
+
* Classes are collected from `twClasses` (frontend) and `twClasses` +
|
|
7
|
+
* `twClassesEditor` + `twClassesEditorOnly` (editor). Any classes nested under
|
|
8
|
+
* an object with `responsive: true` are expanded into all configured
|
|
9
|
+
* breakpoint variants (`{bp}:cls` and `max-{bp}:cls`).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import fs from 'fs';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import { glob } from 'glob';
|
|
15
|
+
|
|
16
|
+
const DEFAULT_BREAKPOINTS = ['sm', 'md'];
|
|
17
|
+
const DEFAULT_MANIFEST_GLOB = 'src/**/manifest.json';
|
|
18
|
+
const FRONTEND_CLASS_KEYS = new Set(['twClasses']);
|
|
19
|
+
const EDITOR_CLASS_KEYS = new Set(['twClasses', 'twClassesEditor', 'twClassesEditorOnly']);
|
|
20
|
+
|
|
21
|
+
const isResponsiveToken = (token, breakpoints) =>
|
|
22
|
+
breakpoints.some((bp) => token.startsWith(`${bp}:`) || token.startsWith(`max-${bp}:`));
|
|
23
|
+
|
|
24
|
+
const addClasses = (value, breakpoints, output, isResponsive = false) => {
|
|
25
|
+
if (!value) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
value.forEach((item) => addClasses(item, breakpoints, output, isResponsive));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof value === 'object') {
|
|
35
|
+
const nextResponsive = isResponsive || value.responsive === true;
|
|
36
|
+
|
|
37
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
38
|
+
if (key !== 'responsive') {
|
|
39
|
+
addClasses(item, breakpoints, output, nextResponsive);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (typeof value !== 'string') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
value
|
|
51
|
+
.split(/\s+/)
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.forEach((token) => {
|
|
54
|
+
if (isResponsiveToken(token, breakpoints)) {
|
|
55
|
+
output.add(token);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (isResponsive) {
|
|
60
|
+
breakpoints.forEach((bp) => {
|
|
61
|
+
output.add(`${bp}:${token}`);
|
|
62
|
+
output.add(`max-${bp}:${token}`);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const collectTailwindClasses = (value, allowedKeys, breakpoints, output) => {
|
|
69
|
+
if (!value || typeof value !== 'object') {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (Array.isArray(value)) {
|
|
74
|
+
value.forEach((item) => collectTailwindClasses(item, allowedKeys, breakpoints, output));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
79
|
+
if (allowedKeys.has(key)) {
|
|
80
|
+
addClasses(item, breakpoints, output, value.responsive === true);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
collectTailwindClasses(item, allowedKeys, breakpoints, output);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const processManifest = (jsonPath, breakpoints) => {
|
|
89
|
+
const content = fs.readFileSync(jsonPath, 'utf-8');
|
|
90
|
+
const json = JSON.parse(content);
|
|
91
|
+
const frontend = new Set();
|
|
92
|
+
const editor = new Set();
|
|
93
|
+
|
|
94
|
+
collectTailwindClasses(json, FRONTEND_CLASS_KEYS, breakpoints, frontend);
|
|
95
|
+
collectTailwindClasses(json, EDITOR_CLASS_KEYS, breakpoints, editor);
|
|
96
|
+
|
|
97
|
+
return { frontend, editor };
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const runPreprocess = ({ projectDir, breakpoints, manifestGlob, outputFrontend, outputEditor }) => {
|
|
101
|
+
const matches = glob.sync(manifestGlob, { cwd: projectDir, absolute: true });
|
|
102
|
+
|
|
103
|
+
const frontend = new Set();
|
|
104
|
+
const editor = new Set();
|
|
105
|
+
|
|
106
|
+
matches.forEach((filePath) => {
|
|
107
|
+
const result = processManifest(filePath, breakpoints);
|
|
108
|
+
result.frontend.forEach((cls) => frontend.add(cls));
|
|
109
|
+
result.editor.forEach((cls) => editor.add(cls));
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
fs.writeFileSync(outputFrontend, [...frontend].join(' '));
|
|
113
|
+
fs.writeFileSync(outputEditor, [...editor].join(' '));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Factory returning a webpack plugin that regenerates Tailwind class source
|
|
118
|
+
* files before each build and on every manifest change in watch mode.
|
|
119
|
+
*
|
|
120
|
+
* @param {object} options
|
|
121
|
+
* @param {string} options.projectDir Absolute path to the project root.
|
|
122
|
+
* @param {string[]} [options.breakpoints] Tailwind breakpoint prefixes to expand. Defaults to `['sm', 'md']`.
|
|
123
|
+
* @param {string} [options.manifestGlob] Glob (relative to `projectDir`) used to find manifests. Defaults to `src/**\/manifest.json`.
|
|
124
|
+
* @param {{ frontend?: string, editor?: string }} [options.output] Override absolute output paths.
|
|
125
|
+
*/
|
|
126
|
+
export const esTwResponsiveCompiler = ({
|
|
127
|
+
projectDir,
|
|
128
|
+
breakpoints = DEFAULT_BREAKPOINTS,
|
|
129
|
+
manifestGlob = DEFAULT_MANIFEST_GLOB,
|
|
130
|
+
output = {},
|
|
131
|
+
} = {}) => {
|
|
132
|
+
if (!projectDir) {
|
|
133
|
+
throw new Error('esTwResponsiveCompiler: `projectDir` is required.');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const config = {
|
|
137
|
+
projectDir,
|
|
138
|
+
breakpoints,
|
|
139
|
+
manifestGlob,
|
|
140
|
+
outputFrontend: output.frontend ?? path.resolve(projectDir, 'es-tw-frontend-classes.txt'),
|
|
141
|
+
outputEditor: output.editor ?? path.resolve(projectDir, 'es-tw-editor-classes.txt'),
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const run = (label) => {
|
|
145
|
+
console.log(`🔄 ${label}`);
|
|
146
|
+
try {
|
|
147
|
+
runPreprocess(config);
|
|
148
|
+
console.log('✅ Done!');
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error('❌ Failed. ', error);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
apply(compiler) {
|
|
156
|
+
compiler.hooks.beforeRun.tap('EsTwResponsiveCompiler', () => {
|
|
157
|
+
run('Generating Tailwind manifest class sources');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
compiler.hooks.watchRun.tapAsync('EsTwResponsiveCompiler', ({ modifiedFiles }, callback) => {
|
|
161
|
+
const manifestChanged = modifiedFiles && [...modifiedFiles].some((file) => file.includes('manifest.json'));
|
|
162
|
+
|
|
163
|
+
if (manifestChanged) {
|
|
164
|
+
run('A manifest was modified, re-running Tailwind manifest class generation');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
callback();
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
};
|