@maizzle/framework 4.0.0-alpha.7 → 4.0.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.
Files changed (65) hide show
  1. package/.github/media/logo-dark.svg +1 -0
  2. package/.github/media/logo-light.svg +1 -0
  3. package/.github/workflows/nodejs.yml +1 -1
  4. package/README.md +42 -35
  5. package/bin/maizzle +3 -0
  6. package/package.json +12 -7
  7. package/src/commands/serve.js +31 -18
  8. package/src/generators/output/to-string.js +2 -6
  9. package/src/generators/postcss.js +29 -0
  10. package/src/generators/posthtml.js +66 -61
  11. package/src/generators/tailwindcss.js +1 -1
  12. package/src/index.js +17 -13
  13. package/src/transformers/baseUrl.js +33 -9
  14. package/src/transformers/filters/defaultFilters.js +126 -0
  15. package/src/transformers/filters/index.js +55 -0
  16. package/src/transformers/index.js +15 -9
  17. package/src/transformers/inlineCss.js +1 -14
  18. package/src/transformers/minify.js +1 -1
  19. package/src/transformers/prettify.js +16 -9
  20. package/src/transformers/removeInlineBackgroundColor.js +1 -1
  21. package/src/transformers/removeInlinedSelectors.js +70 -0
  22. package/src/transformers/removeUnusedCss.js +40 -20
  23. package/src/transformers/shorthandInlineCSS.js +19 -0
  24. package/src/transformers/sixHex.js +24 -1
  25. package/test/expected/posthtml/component.html +13 -0
  26. package/test/expected/{inheritance.html → posthtml/extend-template.html} +2 -2
  27. package/test/expected/posthtml/fetch.html +5 -0
  28. package/test/expected/posthtml/layout.html +3 -0
  29. package/test/expected/transformers/atimport-in-style.html +15 -0
  30. package/test/expected/transformers/{base-image-url.html → base-url.html} +18 -2
  31. package/test/expected/transformers/filters.html +81 -0
  32. package/test/expected/transformers/preserve-transform-css.html +36 -0
  33. package/test/expected/useConfig.html +9 -9
  34. package/test/fixtures/basic.html +6 -6
  35. package/test/fixtures/posthtml/component.html +19 -0
  36. package/test/fixtures/{inheritance.html → posthtml/extend-template.html} +7 -7
  37. package/test/fixtures/posthtml/fetch.html +9 -0
  38. package/test/fixtures/posthtml/layout.html +11 -0
  39. package/test/fixtures/transformers/atimport-in-style.html +11 -0
  40. package/test/fixtures/transformers/{base-image-url.html → base-url.html} +18 -2
  41. package/test/fixtures/transformers/filters.html +87 -0
  42. package/test/fixtures/transformers/preserve-transform-css.html +25 -0
  43. package/test/fixtures/useConfig.html +9 -9
  44. package/test/stubs/components/component.html +5 -0
  45. package/test/stubs/data.json +14 -0
  46. package/test/stubs/layouts/basic.html +1 -0
  47. package/test/stubs/{layout.html → layouts/full.html} +0 -0
  48. package/test/stubs/{layout-basic.html → layouts/template.html} +5 -5
  49. package/test/stubs/post.css +6 -0
  50. package/test/stubs/tailwind/{preserve.html → content-source.html} +0 -0
  51. package/test/stubs/tailwind/tailwind.css +3 -0
  52. package/test/stubs/template.html +10 -10
  53. package/test/stubs/templates/1.html +1 -1
  54. package/test/stubs/templates/2.test +1 -0
  55. package/test/test-config.js +19 -19
  56. package/test/test-postcss.js +8 -0
  57. package/test/test-posthtml.js +72 -0
  58. package/test/{test-tailwind.js → test-tailwindcss.js} +117 -117
  59. package/test/test-todisk.js +511 -497
  60. package/test/test-tostring.js +32 -16
  61. package/test/test-transformers.js +510 -343
  62. package/src/transformers/transform.js +0 -22
  63. package/test/expected/transformers/transform-postcss.html +0 -19
  64. package/test/stubs/templates/2.html +0 -1
  65. package/test/stubs/templates/3.mzl +0 -1
@@ -0,0 +1 @@
1
+ <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><path d="M322.869 65.213c0-13.843-11.222-25.065-25.065-25.065-13.844 0-25.066 11.222-25.066 25.065v133.683c0 13.843 11.222 25.065 25.066 25.065 13.843 0 25.065-11.222 25.065-25.065V65.213Z" stroke="url(#a)" stroke-width="5" stroke-miterlimit="10"/><path d="M218.012 65.213c0-13.843-11.222-25.065-25.066-25.065-13.843 0-25.065 11.222-25.065 25.065v133.683c0 13.843 11.222 25.065 25.065 25.065 13.844 0 25.066-11.222 25.066-25.065V65.213Z" stroke="url(#b)" stroke-width="5" stroke-miterlimit="10"/><path d="M317.555 80.632c8.53-10.903 6.607-26.656-4.296-35.186-10.903-8.53-26.656-6.608-35.187 4.295L173.403 183.519c-8.531 10.903-6.607 26.657 4.295 35.187 10.903 8.53 26.657 6.607 35.187-4.295l104.67-133.779Z" stroke="url(#c)" stroke-width="5" stroke-miterlimit="10"/><path d="M212.597 80.636c8.53-10.902 6.607-26.656-4.295-35.186-10.903-8.53-26.657-6.608-35.187 4.295L68.445 183.523c-8.53 10.903-6.607 26.657 4.296 35.187 10.902 8.53 26.656 6.607 35.186-4.295l104.67-133.779Z" stroke="url(#d)" stroke-width="5" stroke-miterlimit="10"/><rect x="168" y="234" width="158" height="36" rx="18" fill="#4F46E5"/><path d="M199.116 259v-13.091h7.849v1.406h-6.264v4.424h5.676v1.406h-5.676V259h-1.585Zm10.254 0v-9.818h1.457v1.483h.103c.179-.486.502-.88.971-1.183a2.865 2.865 0 0 1 1.585-.454c.111 0 .25.003.416.007.166.004.292.01.377.019v1.534a4.15 4.15 0 0 0-.352-.057 3.432 3.432 0 0 0-.568-.045c-.478 0-.904.1-1.279.3a2.264 2.264 0 0 0-.882.818 2.21 2.21 0 0 0-.32 1.183V259h-1.508Zm9.586.23a3.991 3.991 0 0 1-1.693-.351 2.909 2.909 0 0 1-1.209-1.03c-.298-.451-.447-.997-.447-1.636 0-.562.111-1.018.332-1.368.222-.354.518-.631.889-.831.371-.2.78-.349 1.227-.447.452-.103.906-.183 1.362-.243.596-.077 1.08-.134 1.451-.173.375-.042.647-.113.818-.211.175-.098.262-.268.262-.511v-.051c0-.631-.173-1.121-.518-1.47-.341-.35-.859-.524-1.553-.524-.72 0-1.285.157-1.694.473-.409.315-.697.652-.863 1.009l-1.432-.511c.256-.596.597-1.061 1.023-1.393.43-.337.899-.571 1.406-.703a5.815 5.815 0 0 1 1.509-.205c.315 0 .677.038 1.086.115.414.072.812.224 1.196.454.387.23.709.577.965 1.042.256.464.383 1.086.383 1.866V259h-1.508v-1.33h-.077c-.102.214-.273.442-.511.684-.239.243-.556.45-.953.62-.396.171-.88.256-1.451.256Zm.231-1.355c.596 0 1.099-.117 1.508-.352a2.39 2.39 0 0 0 1.253-2.077v-1.381c-.064.077-.205.147-.422.211-.213.06-.46.113-.741.16a31.625 31.625 0 0 1-1.445.192 5.737 5.737 0 0 0-1.099.249c-.337.111-.61.279-.819.505-.204.222-.306.524-.306.908 0 .524.193.92.581 1.189.392.264.889.396 1.49.396ZM226.21 259v-9.818h1.457v1.534h.128c.205-.524.535-.931.991-1.221.456-.294 1.003-.441 1.643-.441.647 0 1.186.147 1.617.441.434.29.773.697 1.016 1.221h.102c.252-.507.629-.91 1.132-1.208.503-.303 1.106-.454 1.809-.454.878 0 1.596.275 2.154.825.558.545.837 1.395.837 2.55V259h-1.508v-6.571c0-.724-.199-1.242-.595-1.553a2.2 2.2 0 0 0-1.4-.467c-.69 0-1.225.209-1.604.627-.379.413-.569.937-.569 1.572V259h-1.534v-6.724c0-.559-.181-1.008-.543-1.349-.363-.345-.829-.518-1.4-.518-.392 0-.759.104-1.1.313a2.373 2.373 0 0 0-.818.87c-.204.366-.307.79-.307 1.272V259h-1.508Zm19.761.205c-.946 0-1.762-.209-2.448-.627a4.207 4.207 0 0 1-1.579-1.764c-.367-.759-.55-1.641-.55-2.646 0-1.006.183-1.892.55-2.659.371-.772.886-1.373 1.547-1.803.664-.435 1.44-.652 2.326-.652.512 0 1.017.085 1.515.256.499.17.953.447 1.362.831.409.379.735.882.978 1.508.243.627.364 1.398.364 2.314v.639h-7.568v-1.304h6.034c0-.554-.111-1.048-.332-1.483a2.517 2.517 0 0 0-.934-1.029c-.4-.251-.873-.377-1.419-.377-.6 0-1.12.149-1.559.448a2.945 2.945 0 0 0-1.004 1.15c-.234.473-.351.98-.351 1.521v.87c0 .741.127 1.37.383 1.885.26.512.62.902 1.08 1.17.461.264.995.396 1.605.396.396 0 .754-.055 1.074-.166a2.29 2.29 0 0 0 .837-.511 2.33 2.33 0 0 0 .543-.857l1.458.409a3.226 3.226 0 0 1-.774 1.304 3.764 3.764 0 0 1-1.342.87c-.533.204-1.131.307-1.796.307Zm8.584-.205-2.991-9.818h1.585l2.122 7.517h.102l2.097-7.517h1.611l2.071 7.491h.102l2.122-7.491h1.586L261.97 259h-1.483l-2.148-7.543h-.153L256.038 259h-1.483Zm16.056.205c-.887 0-1.665-.211-2.334-.633-.664-.422-1.184-1.012-1.559-1.771-.371-.758-.556-1.645-.556-2.659 0-1.023.185-1.915.556-2.678.375-.763.895-1.355 1.559-1.777.669-.422 1.447-.633 2.334-.633.886 0 1.661.211 2.326.633.669.422 1.189 1.014 1.56 1.777.375.763.562 1.655.562 2.678 0 1.014-.187 1.901-.562 2.659-.371.759-.891 1.349-1.56 1.771-.665.422-1.44.633-2.326.633Zm0-1.356c.673 0 1.227-.172 1.661-.517a3.05 3.05 0 0 0 .966-1.362 5.23 5.23 0 0 0 .313-1.828 5.28 5.28 0 0 0-.313-1.834 3.096 3.096 0 0 0-.966-1.375c-.434-.349-.988-.524-1.661-.524-.674 0-1.228.175-1.662.524-.435.35-.757.808-.966 1.375a5.28 5.28 0 0 0-.313 1.834c0 .656.105 1.266.313 1.828a3.05 3.05 0 0 0 .966 1.362c.434.345.988.517 1.662.517Zm6.751 1.151v-9.818h1.458v1.483h.102c.179-.486.503-.88.971-1.183a2.868 2.868 0 0 1 1.586-.454c.11 0 .249.003.415.007.166.004.292.01.377.019v1.534a4.176 4.176 0 0 0-.351-.057 3.445 3.445 0 0 0-.569-.045c-.478 0-.904.1-1.279.3-.37.196-.664.469-.882.818a2.21 2.21 0 0 0-.319 1.183V259h-1.509Zm8.104-3.58-.026-1.866h.307l4.295-4.372h1.867l-4.577 4.628h-.128l-1.738 1.61Zm-1.407 3.58v-13.091h1.509V259h-1.509Zm6.239 0-3.835-4.858 1.074-1.048 4.679 5.906h-1.918Z" fill="#fff"/><defs><linearGradient id="a" x1="297.804" y1="40.148" x2="297.804" y2="223.961" gradientUnits="userSpaceOnUse"><stop stop-color="#4F46E5"/><stop offset="1" stop-color="#9C96FF"/></linearGradient><linearGradient id="b" x1="192.946" y1="40.148" x2="192.946" y2="223.961" gradientUnits="userSpaceOnUse"><stop stop-color="#4F46E5"/><stop offset="1" stop-color="#9C96FF"/></linearGradient><linearGradient id="c" x1="313.259" y1="45.446" x2="177.698" y2="218.706" gradientUnits="userSpaceOnUse"><stop stop-color="#4F46E5"/><stop offset="1" stop-color="#9C96FF"/></linearGradient><linearGradient id="d" x1="208.302" y1="45.45" x2="72.741" y2="218.71" gradientUnits="userSpaceOnUse"><stop stop-color="#4F46E5"/><stop offset="1" stop-color="#9C96FF"/></linearGradient></defs></svg>
@@ -0,0 +1 @@
1
+ <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><path d="M322.869 65.213c0-13.843-11.222-25.065-25.065-25.065-13.844 0-25.066 11.222-25.066 25.065v133.683c0 13.843 11.222 25.065 25.066 25.065 13.843 0 25.065-11.222 25.065-25.065V65.213ZM218.012 65.213c0-13.843-11.222-25.065-25.066-25.065-13.843 0-25.065 11.222-25.065 25.065v133.683c0 13.843 11.222 25.065 25.065 25.065 13.844 0 25.066-11.222 25.066-25.065V65.213Z" stroke="#4F46E5" stroke-width="5" stroke-miterlimit="10"/><path d="M317.555 80.632c8.53-10.903 6.607-26.656-4.296-35.186-10.903-8.53-26.656-6.608-35.187 4.295L173.403 183.519c-8.531 10.903-6.607 26.657 4.295 35.187 10.903 8.53 26.657 6.607 35.187-4.295l104.67-133.779ZM212.597 80.636c8.53-10.902 6.607-26.656-4.295-35.186-10.903-8.53-26.657-6.608-35.187 4.295L68.445 183.523c-8.53 10.903-6.607 26.657 4.296 35.187 10.902 8.53 26.656 6.607 35.186-4.295l104.67-133.779Z" stroke="#4F46E5" stroke-width="5" stroke-miterlimit="10"/><rect x="165" y="234" width="158" height="36" rx="18" fill="#4F46E5"/><path d="M197.116 259v-13.091h7.849v1.406h-6.264v4.424h5.676v1.406h-5.676V259h-1.585Zm10.254 0v-9.818h1.457v1.483h.103c.179-.486.502-.88.971-1.183a2.865 2.865 0 0 1 1.585-.454c.111 0 .25.003.416.007.166.004.292.01.377.019v1.534a4.15 4.15 0 0 0-.352-.057 3.432 3.432 0 0 0-.568-.045c-.478 0-.904.1-1.279.3a2.264 2.264 0 0 0-.882.818 2.21 2.21 0 0 0-.32 1.183V259h-1.508Zm9.586.23a3.991 3.991 0 0 1-1.693-.351 2.909 2.909 0 0 1-1.209-1.03c-.298-.451-.447-.997-.447-1.636 0-.562.111-1.018.332-1.368.222-.354.518-.631.889-.831.371-.2.78-.349 1.227-.447.452-.103.906-.183 1.362-.243.596-.077 1.08-.134 1.451-.173.375-.042.647-.113.818-.211.175-.098.262-.268.262-.511v-.051c0-.631-.173-1.121-.518-1.47-.341-.35-.859-.524-1.553-.524-.72 0-1.285.157-1.694.473-.409.315-.697.652-.863 1.009l-1.432-.511c.256-.596.597-1.061 1.023-1.393.43-.337.899-.571 1.406-.703a5.815 5.815 0 0 1 1.509-.205c.315 0 .677.038 1.086.115.414.072.812.224 1.196.454.387.23.709.577.965 1.042.256.464.383 1.086.383 1.866V259h-1.508v-1.33h-.077c-.102.214-.273.442-.511.684-.239.243-.556.45-.953.62-.396.171-.88.256-1.451.256Zm.231-1.355c.596 0 1.099-.117 1.508-.352a2.39 2.39 0 0 0 1.253-2.077v-1.381c-.064.077-.205.147-.422.211-.213.06-.46.113-.741.16a31.625 31.625 0 0 1-1.445.192 5.737 5.737 0 0 0-1.099.249c-.337.111-.61.279-.819.505-.204.222-.306.524-.306.908 0 .524.193.92.581 1.189.392.264.889.396 1.49.396ZM224.21 259v-9.818h1.457v1.534h.128c.205-.524.535-.931.991-1.221.456-.294 1.003-.441 1.643-.441.647 0 1.186.147 1.617.441.434.29.773.697 1.016 1.221h.102c.252-.507.629-.91 1.132-1.208.503-.303 1.106-.454 1.809-.454.878 0 1.596.275 2.154.825.558.545.837 1.395.837 2.55V259h-1.508v-6.571c0-.724-.199-1.242-.595-1.553a2.2 2.2 0 0 0-1.4-.467c-.69 0-1.225.209-1.604.627-.379.413-.569.937-.569 1.572V259h-1.534v-6.724c0-.559-.181-1.008-.543-1.349-.363-.345-.829-.518-1.4-.518-.392 0-.759.104-1.1.313a2.373 2.373 0 0 0-.818.87c-.204.366-.307.79-.307 1.272V259h-1.508Zm19.761.205c-.946 0-1.762-.209-2.448-.627a4.207 4.207 0 0 1-1.579-1.764c-.367-.759-.55-1.641-.55-2.646 0-1.006.183-1.892.55-2.659.371-.772.886-1.373 1.547-1.803.664-.435 1.44-.652 2.326-.652.512 0 1.017.085 1.515.256.499.17.953.447 1.362.831.409.379.735.882.978 1.508.243.627.364 1.398.364 2.314v.639h-7.568v-1.304h6.034c0-.554-.111-1.048-.332-1.483a2.517 2.517 0 0 0-.934-1.029c-.4-.251-.873-.377-1.419-.377-.6 0-1.12.149-1.559.448a2.945 2.945 0 0 0-1.004 1.15c-.234.473-.351.98-.351 1.521v.87c0 .741.127 1.37.383 1.885.26.512.62.902 1.08 1.17.461.264.995.396 1.605.396.396 0 .754-.055 1.074-.166a2.29 2.29 0 0 0 .837-.511 2.33 2.33 0 0 0 .543-.857l1.458.409a3.226 3.226 0 0 1-.774 1.304 3.764 3.764 0 0 1-1.342.87c-.533.204-1.131.307-1.796.307Zm8.584-.205-2.991-9.818h1.585l2.122 7.517h.102l2.097-7.517h1.611l2.071 7.491h.102l2.122-7.491h1.586L259.97 259h-1.483l-2.148-7.543h-.153L254.038 259h-1.483Zm16.056.205c-.887 0-1.665-.211-2.334-.633-.664-.422-1.184-1.012-1.559-1.771-.371-.758-.556-1.645-.556-2.659 0-1.023.185-1.915.556-2.678.375-.763.895-1.355 1.559-1.777.669-.422 1.447-.633 2.334-.633.886 0 1.661.211 2.326.633.669.422 1.189 1.014 1.56 1.777.375.763.562 1.655.562 2.678 0 1.014-.187 1.901-.562 2.659-.371.759-.891 1.349-1.56 1.771-.665.422-1.44.633-2.326.633Zm0-1.356c.673 0 1.227-.172 1.661-.517a3.05 3.05 0 0 0 .966-1.362 5.23 5.23 0 0 0 .313-1.828 5.28 5.28 0 0 0-.313-1.834 3.096 3.096 0 0 0-.966-1.375c-.434-.349-.988-.524-1.661-.524-.674 0-1.228.175-1.662.524-.435.35-.757.808-.966 1.375a5.28 5.28 0 0 0-.313 1.834c0 .656.105 1.266.313 1.828a3.05 3.05 0 0 0 .966 1.362c.434.345.988.517 1.662.517Zm6.751 1.151v-9.818h1.458v1.483h.102c.179-.486.503-.88.971-1.183a2.868 2.868 0 0 1 1.586-.454c.11 0 .249.003.415.007.166.004.292.01.377.019v1.534a4.176 4.176 0 0 0-.351-.057 3.445 3.445 0 0 0-.569-.045c-.478 0-.904.1-1.279.3-.37.196-.664.469-.882.818a2.21 2.21 0 0 0-.319 1.183V259h-1.509Zm8.104-3.58-.026-1.866h.307l4.295-4.372h1.867l-4.577 4.628h-.128l-1.738 1.61Zm-1.407 3.58v-13.091h1.509V259h-1.509Zm6.239 0-3.835-4.858 1.074-1.048 4.679 5.906h-1.918Z" fill="#fff"/></svg>
@@ -14,7 +14,7 @@ jobs:
14
14
 
15
15
  strategy:
16
16
  matrix:
17
- node-version: [12, 14, 16]
17
+ node-version: [14, 16, 18]
18
18
 
19
19
  steps:
20
20
  - uses: actions/checkout@v2
package/README.md CHANGED
@@ -1,35 +1,42 @@
1
- <div align="center">
2
- <p><a href="https://maizzle.com" target="_blank"><img src="https://res.cloudinary.com/maizzle/image/upload/v1553710263/maizzle.svg" width="200" alt="Maizzle"></a></p>
3
- <p>HTML email development framework</p>
4
- <div>
5
-
6
- [![Version][npm-version-shield]][npm]
7
- [![Build][github-ci-shield]][github-ci]
8
- [![Downloads][npm-stats-shield]][npm-stats]
9
- [![License][license-shield]][license]
10
-
11
- </div>
12
- </div>
13
-
14
- ## About
15
-
16
- > **Note:** This repository contains the core code of the Maizzle framework. If you want to build HTML emails using Maizzle, visit the [starter repository](https://github.com/maizzle/maizzle).
17
-
18
- Maizzle is a framework that helps you quickly build HTML emails with [Tailwind CSS](https://tailwindcss.com/).
19
-
20
- ## Documentation
21
-
22
- Maizzle documentation is available at https://maizzle.com
23
-
24
- ## License
25
-
26
- The Maizzle framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
27
-
28
- [npm]: https://www.npmjs.com/package/@maizzle/framework
29
- [npm-stats]: https://npm-stat.com/charts.html?package=%40maizzle%2Fframework&from=2019-03-27
30
- [npm-version-shield]: https://img.shields.io/npm/v/@maizzle/framework.svg?style=flat-square
31
- [npm-stats-shield]: https://img.shields.io/npm/dt/@maizzle/framework.svg?style=flat-square&color=6875f5
32
- [github-ci]: https://github.com/maizzle/framework/actions
33
- [github-ci-shield]: https://img.shields.io/github/workflow/status/maizzle/framework/Node.js%20CI?style=flat-square
34
- [license]: ./LICENSE
35
- [license-shield]: https://img.shields.io/npm/l/@maizzle/framework.svg?style=flat-square&color=0e9f6e
1
+ <div align="center">
2
+ <p>
3
+ <a href="https://maizzle.com/#gh-light-mode-only" target="_blank">
4
+ <img src="./.github/media/logo-light.svg" alt="Maizzle" width="300">
5
+ </a>
6
+ <a href="https://maizzle.com/#gh-dark-mode-only" target="_blank">
7
+ <img src="./.github/media/logo-dark.svg" alt="Maizzle" width="300">
8
+ </a>
9
+ </p>
10
+ <p>Quickly build HTML emails with utility-first CSS</p>
11
+ <div>
12
+
13
+ [![Version][npm-version-shield]][npm]
14
+ [![Build][github-ci-shield]][github-ci]
15
+ [![Downloads][npm-stats-shield]][npm-stats]
16
+ [![License][license-shield]][license]
17
+
18
+ </div>
19
+ </div>
20
+
21
+ ## About
22
+
23
+ > **Note:** This repository contains the core code of the Maizzle framework. If you want to build HTML emails using Maizzle, visit the [Starter repository](https://github.com/maizzle/maizzle).
24
+
25
+ Maizzle is a framework that helps you quickly build HTML emails with [Tailwind CSS](https://tailwindcss.com/).
26
+
27
+ ## Documentation
28
+
29
+ Maizzle documentation is available at https://maizzle.com
30
+
31
+ ## License
32
+
33
+ The Maizzle framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
34
+
35
+ [npm]: https://www.npmjs.com/package/@maizzle/framework
36
+ [npm-stats]: https://npm-stat.com/charts.html?package=%40maizzle%2Fframework&from=2019-03-27
37
+ [npm-version-shield]: https://img.shields.io/npm/v/@maizzle/framework.svg?style=flat-square
38
+ [npm-stats-shield]: https://img.shields.io/npm/dt/@maizzle/framework.svg?style=flat-square&color=4f46e5
39
+ [github-ci]: https://github.com/maizzle/framework/actions
40
+ [github-ci-shield]: https://img.shields.io/github/workflow/status/maizzle/framework/Node.js%20CI?style=flat-square
41
+ [license]: ./LICENSE
42
+ [license-shield]: https://img.shields.io/npm/l/@maizzle/framework.svg?style=flat-square&color=0e9f6e
package/bin/maizzle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('@maizzle/cli')
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "4.0.0-alpha.7",
3
+ "version": "4.0.0",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "main": "src/index.js",
7
+ "bin": {
8
+ "maizzle": "bin/maizzle"
9
+ },
7
10
  "repository": {
8
11
  "type": "git",
9
12
  "url": "https://github.com/maizzle/framework.git"
@@ -33,10 +36,11 @@
33
36
  "release": "np"
34
37
  },
35
38
  "dependencies": {
39
+ "@maizzle/cli": "^1.5.0",
36
40
  "autoprefixer": "^10.4.0",
37
41
  "browser-sync": "^2.26.13",
38
42
  "color-shorthand-hex-to-six-digit": "^3.0.2",
39
- "email-comb": "^5.0.0",
43
+ "email-comb": "^5.2.0",
40
44
  "front-matter": "^4.0.0",
41
45
  "fs-extra": "^10.0.0",
42
46
  "glob-promise": "^4.1.0",
@@ -51,17 +55,18 @@
51
55
  "posthtml": "^0.16.6",
52
56
  "posthtml-attrs-parser": "^0.1.1",
53
57
  "posthtml-base-url": "^1.0.1",
54
- "posthtml-content": "^0.0.3",
58
+ "posthtml-content": "^0.1.0",
55
59
  "posthtml-expressions": "^1.8.1",
56
60
  "posthtml-extend": "^0.6.0",
57
61
  "posthtml-extra-attributes": "^1.0.0",
58
- "posthtml-fetch": "^2.0.0",
62
+ "posthtml-fetch": "^2.2.0",
59
63
  "posthtml-markdownit": "^1.3.0",
60
- "posthtml-modules": "^0.8.1",
64
+ "posthtml-match-helper": "^1.0.3",
65
+ "posthtml-modules": "^0.9.0",
61
66
  "posthtml-mso": "^1.0.4",
62
67
  "posthtml-postcss-merge-longhand": "^1.0.2",
63
68
  "posthtml-remove-attributes": "^1.0.0",
64
- "posthtml-safe-class-names": "^1.0.4",
69
+ "posthtml-safe-class-names": "^1.0.8",
65
70
  "posthtml-url-parameters": "^1.0.4",
66
71
  "pretty": "^2.0.0",
67
72
  "prevent-widows": "^1.0.2",
@@ -76,7 +81,7 @@
76
81
  "xo": "0.39.1"
77
82
  },
78
83
  "engines": {
79
- "node": ">=12.13.0"
84
+ "node": ">=14.0.0"
80
85
  },
81
86
  "ava": {
82
87
  "files": [
@@ -41,13 +41,27 @@ const serve = async (env = 'local', config = {}) => {
41
41
  const globalPaths = [
42
42
  'src/**',
43
43
  get(config, 'build.tailwind.config', 'tailwind.config.js'),
44
- [...new Set(get(config, 'build.browsersync.watch', []))]
44
+ ...new Set(get(config, 'build.browsersync.watch', []))
45
45
  ]
46
46
 
47
47
  // Watch for Template file changes
48
48
  browsersync()
49
49
  .watch(templatePaths)
50
50
  .on('change', async file => {
51
+ if (config.events && typeof config.events.beforeCreate === 'function') {
52
+ await config.events.beforeCreate(config)
53
+ }
54
+
55
+ // Don't render if file type is not configured
56
+ // eslint-disable-next-line
57
+ const filetypes = templates.reduce((acc, template) => {
58
+ return [...acc, ...get(template, 'filetypes', ['html'])]
59
+ }, [])
60
+
61
+ if (!filetypes.includes(path.extname(file).slice(1))) {
62
+ return
63
+ }
64
+
51
65
  if (get(config, 'build.console.clear')) {
52
66
  clearConsole()
53
67
  }
@@ -58,10 +72,6 @@ const serve = async (env = 'local', config = {}) => {
58
72
 
59
73
  file = file.replace(/\\/g, '/')
60
74
 
61
- if (config.events && typeof config.events.beforeCreate === 'function') {
62
- await config.events.beforeCreate(config)
63
- }
64
-
65
75
  const renderOptions = {
66
76
  maizzle: config,
67
77
  ...config.events
@@ -121,19 +131,22 @@ const serve = async (env = 'local', config = {}) => {
121
131
 
122
132
  // Initialize Browsersync
123
133
  browsersync()
124
- .init({
125
- notify: false,
126
- open: false,
127
- port: 3000,
128
- server: {
129
- baseDir,
130
- directory: true
131
- },
132
- tunnel: false,
133
- ui: {port: 3001},
134
- logFileChanges: false,
135
- ...get(config, 'build.browsersync', {})
136
- }, () => {})
134
+ .init(
135
+ merge(
136
+ {
137
+ notify: false,
138
+ open: false,
139
+ port: 3000,
140
+ server: {
141
+ baseDir,
142
+ directory: true
143
+ },
144
+ tunnel: false,
145
+ ui: {port: 3001},
146
+ logFileChanges: false
147
+ },
148
+ get(config, 'build.browsersync', {})
149
+ ), () => {})
137
150
  } catch (error) {
138
151
  spinner.fail(error)
139
152
  throw error
@@ -22,13 +22,9 @@ module.exports = async (html, options) => {
22
22
  let config = merge(fileConfig, get(options, 'maizzle', {}))
23
23
 
24
24
  const tailwindConfig = get(options, 'tailwind.config', {})
25
- const cssString = get(options, 'tailwind.css', '@tailwind components; @tailwind utilities;')
25
+ const cssString = get(options, 'tailwind.css', '')
26
26
 
27
- let {frontmatter} = fm(html)
28
-
29
- if (frontmatter) {
30
- frontmatter = await posthtml(frontmatter, config)
31
- }
27
+ const {frontmatter} = fm(html)
32
28
 
33
29
  html = `---\n${frontmatter}\n---\n\n${fm(html).body}`
34
30
 
@@ -0,0 +1,29 @@
1
+ const path = require('path')
2
+ const {get} = require('lodash')
3
+ const postcss = require('postcss')
4
+ const postcssImport = require('postcss-import')
5
+ const postcssNested = require('tailwindcss/nesting')
6
+ const mergeLonghand = require('postcss-merge-longhand')
7
+
8
+ module.exports = {
9
+ process: async (css = '', maizzleConfig = {}, spinner = null) => {
10
+ const userFilePath = get(maizzleConfig, 'build.tailwind.css', path.join(process.cwd(), 'src/css/tailwind.css'))
11
+
12
+ return postcss([
13
+ postcssImport({path: path.dirname(userFilePath)}),
14
+ postcssNested(),
15
+ maizzleConfig.env === 'local' ? () => {} : mergeLonghand(),
16
+ ...get(maizzleConfig, 'build.postcss.plugins', [])
17
+ ])
18
+ .process(css, {from: undefined})
19
+ .then(result => result.css)
20
+ .catch(error => {
21
+ console.error(error)
22
+ if (spinner) {
23
+ spinner.stop()
24
+ }
25
+
26
+ throw new Error(`PostCSS processing failed`)
27
+ })
28
+ }
29
+ }
@@ -1,61 +1,66 @@
1
- const fm = require('front-matter')
2
- const posthtml = require('posthtml')
3
- const {get, merge} = require('lodash')
4
- const fetch = require('posthtml-fetch')
5
- const layouts = require('posthtml-extend')
6
- const modules = require('posthtml-modules')
7
- const expressions = require('posthtml-expressions')
8
-
9
- module.exports = async (html, config) => {
10
- const layoutsOptions = get(config, 'build.layouts', {})
11
-
12
- const fetchOptions = get(config, 'build.posthtml.fetch', {})
13
- const fetchPlugin = fetch({...fetchOptions})
14
-
15
- const modulesOptions = get(config, 'build.components', {})
16
- // Fake `from` option so we can reference modules relatively
17
- const modulesRoot = modulesOptions.root || './'
18
- const modulesFrom = modulesOptions.from || `${modulesRoot}/fake`
19
-
20
- const posthtmlOptions = get(config, 'build.posthtml.options', {})
21
- const posthtmlPlugins = get(config, 'build.posthtml.plugins', [])
22
-
23
- const expressionsOptions = merge({strictMode: false}, get(config, 'build.posthtml.expressions', {}))
24
-
25
- const locals = merge(
26
- get(expressionsOptions, 'locals', {}),
27
- get(config, 'locals', {}),
28
- {page: config}
29
- )
30
-
31
- return posthtml([
32
- fetchPlugin,
33
- layouts(
34
- merge(
35
- {
36
- strict: false,
37
- plugins: [
38
- expressions({...expressionsOptions, locals})
39
- ]
40
- },
41
- layoutsOptions
42
- )
43
- ),
44
- modules({
45
- parser: posthtmlOptions,
46
- attributeAsLocals: true,
47
- from: modulesFrom,
48
- root: modulesRoot,
49
- tag: 'component',
50
- attribute: 'src',
51
- plugins: [
52
- fetchPlugin
53
- ],
54
- locals,
55
- ...modulesOptions
56
- }),
57
- ...posthtmlPlugins
58
- ])
59
- .process(html, {...posthtmlOptions})
60
- .then(result => fm(result.html).body)
61
- }
1
+ const fm = require('front-matter')
2
+ const posthtml = require('posthtml')
3
+ const {get, merge} = require('lodash')
4
+ const fetch = require('posthtml-fetch')
5
+ const layouts = require('posthtml-extend')
6
+ const modules = require('posthtml-modules')
7
+ const expressions = require('posthtml-expressions')
8
+
9
+ module.exports = async (html, config) => {
10
+ const layoutsOptions = get(config, 'build.layouts', {})
11
+
12
+ const modulesOptions = get(config, 'build.components', {})
13
+ // Fake `from` option so we can reference modules relatively
14
+ const modulesRoot = modulesOptions.root || './'
15
+ const modulesFrom = modulesOptions.from || `${modulesRoot}/fake`
16
+
17
+ const posthtmlOptions = get(config, 'build.posthtml.options', {})
18
+ const posthtmlPlugins = get(config, 'build.posthtml.plugins', [])
19
+
20
+ const expressionsOptions = merge({strictMode: false}, get(config, 'build.posthtml.expressions', {}))
21
+
22
+ const locals = merge(
23
+ get(expressionsOptions, 'locals', {}),
24
+ get(config, 'locals', {}),
25
+ {page: config}
26
+ )
27
+
28
+ const fetchPlugin = fetch(
29
+ merge(
30
+ {
31
+ expressions: merge({...expressionsOptions, locals})
32
+ },
33
+ get(config, 'build.posthtml.fetch', {})
34
+ )
35
+ )
36
+
37
+ return posthtml([
38
+ fetchPlugin,
39
+ expressions({...expressionsOptions, locals}),
40
+ layouts(
41
+ merge(
42
+ {
43
+ strict: false,
44
+ expressions: merge({...expressionsOptions, locals})
45
+ },
46
+ layoutsOptions
47
+ )
48
+ ),
49
+ modules({
50
+ parser: posthtmlOptions,
51
+ attributeAsLocals: true,
52
+ from: modulesFrom,
53
+ root: modulesRoot,
54
+ tag: 'component',
55
+ attribute: 'src',
56
+ plugins: [
57
+ fetchPlugin
58
+ ],
59
+ locals,
60
+ ...modulesOptions
61
+ }),
62
+ ...posthtmlPlugins
63
+ ])
64
+ .process(html, {...posthtmlOptions})
65
+ .then(result => fm(result.html).body)
66
+ }
@@ -92,7 +92,7 @@ module.exports = {
92
92
  if (userFileExists) {
93
93
  css = await fs.readFile(path.resolve(userFilePath), 'utf8') + css
94
94
  } else {
95
- css = '@import "tailwindcss/components"; @import "tailwindcss/utilities";' + css
95
+ css = `@import "tailwindcss/components"; @import "tailwindcss/utilities"; ${css}`
96
96
  }
97
97
 
98
98
  return postcss([
package/src/index.js CHANGED
@@ -1,13 +1,17 @@
1
- const serve = require('./commands/serve')
2
- const toFile = require('./commands/build')
3
- const transformers = require('./transformers')
4
- const toString = require('./functions/render')
5
- const toPlaintext = require('./functions/plaintext')
6
-
7
- module.exports = {
8
- serve,
9
- build: toFile,
10
- ...transformers,
11
- render: toString,
12
- plaintext: toPlaintext
13
- }
1
+ const serve = require('./commands/serve')
2
+ const toFile = require('./commands/build')
3
+ const transformers = require('./transformers')
4
+ const toString = require('./functions/render')
5
+ const PostCSS = require('./generators/postcss')
6
+ const toPlaintext = require('./functions/plaintext')
7
+ const TailwindCSS = require('./generators/tailwindcss')
8
+
9
+ module.exports = {
10
+ serve,
11
+ build: toFile,
12
+ ...transformers,
13
+ render: toString,
14
+ postcss: PostCSS,
15
+ plaintext: toPlaintext,
16
+ tailwindcss: TailwindCSS
17
+ }
@@ -3,17 +3,41 @@ const isUrl = require('is-url-superb')
3
3
  const baseUrl = require('posthtml-base-url')
4
4
  const {get, isObject, isEmpty} = require('lodash')
5
5
 
6
- // VML backgrounds need regex because they're inside HTML comments :(
6
+ /**
7
+ * VML backgrounds must be handled with regex because
8
+ * they're inside HTML comments.
9
+ */
7
10
  const rewriteVMLs = (html, url) => {
8
- const vImageMatch = html.match(/(<v:image.+)(src=['"]([^'"]+)['"])/)
9
- const vFillMatch = html.match(/(<v:fill.+)(src=['"]([^'"]+)['"])/)
11
+ // Handle <v:image>
12
+ const vImageMatches = html.match(/<v:image[^>]+src="?([^"\s]+)"/g)
10
13
 
11
- if (vImageMatch && !isUrl(vImageMatch[3])) {
12
- html = html.replace(vImageMatch[0], `${vImageMatch[1]}src="${url}${vImageMatch[3]}"`)
14
+ if (vImageMatches) {
15
+ vImageMatches.forEach(match => {
16
+ const vImage = match.match(/<v:image[^>]+src="?([^"\s]+)"/)
17
+ const vImageSrc = vImage[1]
18
+
19
+ if (!isUrl(vImageSrc)) {
20
+ const vImageSrcUrl = url + vImageSrc
21
+ const vImageReplace = vImage[0].replace(vImageSrc, vImageSrcUrl)
22
+ html = html.replace(vImage[0], vImageReplace)
23
+ }
24
+ })
13
25
  }
14
26
 
15
- if (vFillMatch && !isUrl(vFillMatch[3])) {
16
- html = html.replace(vFillMatch[0], `${vFillMatch[1]}src="${url}${vFillMatch[3]}"`)
27
+ // Handle <v:fill>
28
+ const vFillMatches = html.match(/<v:fill[^>]+src="?([^"\s]+)"/g)
29
+
30
+ if (vFillMatches) {
31
+ vFillMatches.forEach(match => {
32
+ const vFill = match.match(/<v:fill[^>]+src="?([^"\s]+)"/)
33
+ const vFillSrc = vFill[1]
34
+
35
+ if (!isUrl(vFillSrc)) {
36
+ const vFillSrcUrl = url + vFillSrc
37
+ const vFillReplace = vFill[0].replace(vFillSrc, vFillSrcUrl)
38
+ html = html.replace(vFill[0], vFillReplace)
39
+ }
40
+ })
17
41
  }
18
42
 
19
43
  return html
@@ -23,7 +47,7 @@ module.exports = async (html, config = {}, direct = false) => {
23
47
  const url = direct ? config : get(config, 'baseURL')
24
48
  const posthtmlOptions = get(config, 'build.posthtml.options', {})
25
49
 
26
- // `baseUrl` as a string
50
+ // Handle `baseUrl` as a string
27
51
  if (typeof url === 'string' && url.length > 0) {
28
52
  html = rewriteVMLs(html, url)
29
53
 
@@ -34,7 +58,7 @@ module.exports = async (html, config = {}, direct = false) => {
34
58
  .then(result => result.html)
35
59
  }
36
60
 
37
- // `baseUrl: {}`
61
+ // Handle `baseUrl` as an object
38
62
  if (isObject(url) && !isEmpty(url)) {
39
63
  html = rewriteVMLs(html, url.url)
40
64