@newlogic-digital/core 3.0.0-next.3 → 3.0.0-next.4
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +31 -75
- package/package.json +10 -10
- package/types/index.d.ts +1 -1
package/index.js
CHANGED
@@ -1,45 +1,18 @@
|
|
1
1
|
import fs from 'node:fs'
|
2
2
|
import os from 'node:os'
|
3
|
-
import {
|
4
|
-
import postHtml from 'posthtml'
|
3
|
+
import { resolve, join } from 'node:path'
|
5
4
|
import vituum from 'vituum'
|
6
|
-
import posthtml from '@vituum/vite-plugin-posthtml'
|
7
5
|
import latte from '@vituum/vite-plugin-latte'
|
8
6
|
import twig from '@vituum/vite-plugin-twig'
|
9
7
|
import juice from '@vituum/vite-plugin-juice'
|
10
8
|
import send from '@vituum/vite-plugin-send'
|
11
9
|
import tailwindcss from '@vituum/vite-plugin-tailwindcss'
|
12
10
|
import { getPackageInfo, merge } from 'vituum/utils/common.js'
|
13
|
-
import highlight from './src/prism.js'
|
14
11
|
import twigOptions from './src/twig.js'
|
15
|
-
import FastGlob from 'fast-glob'
|
16
|
-
import fse from 'fs-extra'
|
17
|
-
import pc from 'picocolors'
|
18
12
|
import browserslistToEsbuild from 'browserslist-to-esbuild'
|
19
13
|
|
20
14
|
const { name } = getPackageInfo(import.meta.url)
|
21
15
|
|
22
|
-
const posthtmlPrism = {
|
23
|
-
name: '@newlogic-digital/vite-plugin-posthtml-prism',
|
24
|
-
enforce: 'post',
|
25
|
-
transformIndexHtml: {
|
26
|
-
order: 'post',
|
27
|
-
handler: async (html, { filename }) => {
|
28
|
-
filename = filename.replace('?raw', '')
|
29
|
-
|
30
|
-
if (!filename.replace('.html', '').endsWith('ui.json')) {
|
31
|
-
return
|
32
|
-
}
|
33
|
-
|
34
|
-
const plugins = [highlight({ inline: false })]
|
35
|
-
|
36
|
-
const result = await postHtml(plugins).process(html)
|
37
|
-
|
38
|
-
return result.html
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
16
|
const postcssImportSupports = {
|
44
17
|
name: 'postcss-import-supports',
|
45
18
|
transform(code, path) {
|
@@ -59,30 +32,22 @@ const defaultOptions = {
|
|
59
32
|
cert: 'localhost',
|
60
33
|
format: ['latte'],
|
61
34
|
manualChunks: {},
|
62
|
-
emails: {
|
63
|
-
outputDir: resolve(process.cwd(), 'public/email'),
|
64
|
-
appDir: resolve(process.cwd(), 'app/Templates/Emails')
|
65
|
-
},
|
66
35
|
vituum: {
|
67
36
|
pages: {
|
68
37
|
dir: './src/pages'
|
69
38
|
}
|
70
39
|
},
|
71
|
-
posthtml: {
|
72
|
-
root: resolve(process.cwd(), 'src')
|
73
|
-
},
|
74
40
|
juice: {
|
75
41
|
paths: ['src/pages/email'],
|
76
42
|
postcss: {
|
77
43
|
globalData: {
|
78
|
-
files: ['./src/
|
44
|
+
files: ['./src/styles/emails/theme/config.css']
|
79
45
|
}
|
80
46
|
}
|
81
47
|
},
|
82
48
|
tailwindcss: {},
|
83
49
|
send: {},
|
84
50
|
latte: {
|
85
|
-
renderTransformedHtml: filename => dirname(filename).endsWith('email'),
|
86
51
|
globals: {
|
87
52
|
srcPath: resolve(process.cwd(), 'src'),
|
88
53
|
templatesPath: resolve(process.cwd(), 'src/templates'),
|
@@ -96,8 +61,7 @@ const defaultOptions = {
|
|
96
61
|
filters: {
|
97
62
|
json: resolve(process.cwd(), 'node_modules/@newlogic-digital/core/latte/JsonFilter.js'),
|
98
63
|
code: 'node_modules/@newlogic-digital/core/latte/CodeFilter.php'
|
99
|
-
}
|
100
|
-
ignoredPaths: ['**/views/email/**/!(*.test).latte', '**/emails/!(*.test).latte']
|
64
|
+
}
|
101
65
|
},
|
102
66
|
twig: twigOptions
|
103
67
|
}
|
@@ -122,11 +86,9 @@ const plugin = (options = {}) => {
|
|
122
86
|
const plugins = [
|
123
87
|
vituum(options.vituum),
|
124
88
|
tailwindcss(options.tailwindcss),
|
125
|
-
posthtml(options.posthtml),
|
126
89
|
...templatesPlugins,
|
127
90
|
juice(options.juice),
|
128
91
|
send(options.send),
|
129
|
-
posthtmlPrism,
|
130
92
|
postcssImportSupports
|
131
93
|
]
|
132
94
|
|
@@ -160,15 +122,6 @@ const plugin = (options = {}) => {
|
|
160
122
|
userConfig.publicDir = userConfig.publicDir ?? false
|
161
123
|
}
|
162
124
|
|
163
|
-
if (options.mode === 'emails') {
|
164
|
-
userEnv.mode = 'production'
|
165
|
-
|
166
|
-
defaultInput = [
|
167
|
-
'./src/pages/email/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
|
168
|
-
'!./src/pages/email/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json'
|
169
|
-
]
|
170
|
-
}
|
171
|
-
|
172
125
|
const outDir = resolve(userConfig.root ?? process.cwd(), 'public')
|
173
126
|
|
174
127
|
if (userConfig.build && !userConfig.build.outDir) {
|
@@ -181,24 +134,41 @@ const plugin = (options = {}) => {
|
|
181
134
|
|
182
135
|
userConfig.build = Object.assign({
|
183
136
|
target: browserslistToEsbuild(),
|
184
|
-
manifest: 'manifest.json',
|
137
|
+
manifest: (options.mode === 'emails') ? false : 'manifest.json',
|
185
138
|
emptyOutDir: false,
|
186
139
|
modulePreload: false,
|
187
140
|
assetsInlineLimit: 0,
|
188
141
|
outDir
|
189
142
|
}, userConfig.build ?? {})
|
190
143
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
144
|
+
if (options.mode === 'emails') {
|
145
|
+
userEnv.mode = 'production'
|
146
|
+
|
147
|
+
defaultInput = [
|
148
|
+
'./src/pages/email/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
|
149
|
+
'./src/styles/emails/*.{css,pcss,scss,sass,less,styl,stylus}',
|
150
|
+
'!./src/pages/email/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json'
|
151
|
+
]
|
152
|
+
|
153
|
+
userConfig.build.rollupOptions = Object.assign({
|
154
|
+
input: defaultInput,
|
155
|
+
output: {
|
156
|
+
assetFileNames: 'assets/email/[name].[ext]'
|
157
|
+
}
|
158
|
+
}, userConfig.build.rollupOptions ?? {})
|
159
|
+
} else {
|
160
|
+
userConfig.build.rollupOptions = Object.assign({
|
161
|
+
input: defaultInput,
|
162
|
+
output: {
|
163
|
+
manualChunks: {
|
164
|
+
swup: ['swup'],
|
165
|
+
stimulus: ['@hotwired/stimulus'],
|
166
|
+
naja: ['naja'],
|
167
|
+
...options.manualChunks
|
168
|
+
}
|
199
169
|
}
|
200
|
-
}
|
201
|
-
}
|
170
|
+
}, userConfig.build.rollupOptions ?? {})
|
171
|
+
}
|
202
172
|
|
203
173
|
userConfig.server = Object.assign({
|
204
174
|
host: true,
|
@@ -212,20 +182,6 @@ const plugin = (options = {}) => {
|
|
212
182
|
}
|
213
183
|
: false
|
214
184
|
}, userConfig.server ?? {})
|
215
|
-
},
|
216
|
-
writeBundle: async () => {
|
217
|
-
if (options.mode === 'emails') {
|
218
|
-
const emails = FastGlob.sync(`${resolve(process.cwd(), options.emails.outputDir)}/**`).filter(entry => !entry.endsWith('test.html'))
|
219
|
-
const emailsProd = emails.map((path) => {
|
220
|
-
return path.replace(resolve(process.cwd(), options.emails.outputDir), resolve(process.cwd(), options.emails.appDir)).replace('.html', '.latte')
|
221
|
-
})
|
222
|
-
|
223
|
-
await Promise.all(emails.map((file, i) =>
|
224
|
-
fse.move(file, emailsProd[i], { overwrite: true })
|
225
|
-
))
|
226
|
-
|
227
|
-
console.info(`${pc.cyan('@newlogic-digital/core')} ${pc.green(`all email files were moved to ${relative(process.cwd(), options.emails.appDir)}`)}`)
|
228
|
-
}
|
229
185
|
}
|
230
186
|
}, ...plugins]
|
231
187
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@newlogic-digital/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.0.0-next.
|
4
|
+
"version": "3.0.0-next.4",
|
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",
|
@@ -12,30 +12,30 @@
|
|
12
12
|
"publish-next": "npm publish --tag next"
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
|
-
"@vituum/vite-plugin-juice": "^1.
|
15
|
+
"@vituum/vite-plugin-juice": "^1.3.0",
|
16
16
|
"@vituum/vite-plugin-latte": "^1.2.1",
|
17
17
|
"@vituum/vite-plugin-posthtml": "^1.1.0",
|
18
18
|
"@vituum/vite-plugin-send": "^1.1.0",
|
19
|
-
"@vituum/vite-plugin-tailwindcss": "^1.
|
19
|
+
"@vituum/vite-plugin-tailwindcss": "^1.2.0",
|
20
20
|
"@vituum/vite-plugin-twig": "^1.1.0",
|
21
21
|
"fast-glob": "^3.3.2",
|
22
22
|
"fs-extra": "^11.2.0",
|
23
23
|
"html-minifier-terser": "^7.2.0",
|
24
24
|
"lodash": "^4.17.21",
|
25
|
-
"picocolors": "^1.0
|
25
|
+
"picocolors": "^1.1.0",
|
26
26
|
"posthtml": "^0.16.6",
|
27
27
|
"posthtml-prism": "^2.0.1",
|
28
28
|
"prismjs": "^1.29.0",
|
29
29
|
"vituum": "^1.1.1",
|
30
|
-
"browserslist": "^4.
|
30
|
+
"browserslist": "^4.24.0",
|
31
31
|
"browserslist-to-esbuild": "^2.1.1"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
|
-
"@types/node": "^22.
|
35
|
-
"eslint": "^9.
|
36
|
-
"neostandard": "^0.11.
|
37
|
-
"typescript": "^5.
|
38
|
-
"vite": "^5.4.
|
34
|
+
"@types/node": "^22.7.5",
|
35
|
+
"eslint": "^9.12.0",
|
36
|
+
"neostandard": "^0.11.6",
|
37
|
+
"typescript": "^5.6.2",
|
38
|
+
"vite": "^5.4.8"
|
39
39
|
},
|
40
40
|
"files": [
|
41
41
|
"latte",
|
package/types/index.d.ts
CHANGED