@newlogic-digital/core 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +24 -1
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -5,6 +5,7 @@ import latte from '@vituum/latte'
5
5
  import lodash from 'lodash'
6
6
  import minifier from 'html-minifier-terser'
7
7
  import fs from 'fs'
8
+ import fse from 'fs-extra'
8
9
  import { dirname, resolve } from 'path'
9
10
  import postHtml from 'posthtml'
10
11
  import highlight from './prism.js'
@@ -15,6 +16,8 @@ import postcssNesting from 'postcss-nesting'
15
16
  import postcssCustomMedia from 'postcss-custom-media'
16
17
  import postcssCustomSelectors from 'postcss-custom-selectors'
17
18
  import autoprefixer from 'autoprefixer'
19
+ import chalk from 'chalk'
20
+ import FastGlob from 'fast-glob'
18
21
 
19
22
  const posthtmlPrism = {
20
23
  name: '@vituum/vite-plugin-posthtml-prism',
@@ -82,6 +85,10 @@ const parseMinifyHtml = async (input, name) => {
82
85
 
83
86
  const defaultConfig = {
84
87
  format: 'twig',
88
+ emails: {
89
+ outputDir: resolve(process.cwd(), 'public/emails'),
90
+ prodDir: resolve(process.cwd(), 'app/Templates/Emails')
91
+ },
85
92
  posthtml: {},
86
93
  juice: {},
87
94
  tailwind: {},
@@ -256,7 +263,23 @@ const integration = (userConfig = {}) => {
256
263
 
257
264
  return {
258
265
  config: {
259
- integrations: [posthtml(userConfig.posthtml), juice(userConfig.juice), twig(userConfig.twig), latte(userConfig.latte)],
266
+ integrations: [posthtml(userConfig.posthtml), juice(userConfig.juice), twig(userConfig.twig), latte(userConfig.latte), {
267
+ task: {
268
+ name: 'emails',
269
+ action: async () => {
270
+ const emails = FastGlob.sync(`${resolve(process.cwd(), userConfig.emails.outputDir)}/**`).filter(entry => entry.endsWith('prod.html'))
271
+ const emailsProd = emails.map(path => {
272
+ return path.replace(resolve(process.cwd(), userConfig.emails.outputDir), resolve(process.cwd(), userConfig.emails.prodDir)).replace('.prod.html', '.latte')
273
+ })
274
+
275
+ await Promise.all(emails.map((file, i) =>
276
+ fse.move(file, emailsProd[i])
277
+ ))
278
+
279
+ console.info(`${chalk.cyan(`newlogic-core`)} ${chalk.green('all email files moved')}`)
280
+ }
281
+ }
282
+ }],
260
283
  plugins: [posthtmlPrism],
261
284
  server: {
262
285
  open: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@newlogic-digital/core",
3
3
  "type": "module",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "main": "index.js",
6
6
  "author": "New Logic Studio s.r.o.",
7
7
  "description": "Set of tools that can be used to create modern web applications",
@@ -19,7 +19,7 @@
19
19
  "prismjs": "^1.29.0",
20
20
  "html-minifier-terser": "^7.0.0",
21
21
  "lodash": "^4.17.21",
22
- "vituum": "^0.0.29"
22
+ "vituum": "^0.0.32"
23
23
  },
24
24
  "files": [
25
25
  "latte",