@newlogic-digital/core 2.0.0-alpha.8 → 2.0.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +28 -14
- package/latte/JsonFilter.js +7 -0
- package/package.json +13 -8
- package/types/index.d.ts +18 -0
package/index.js
CHANGED
@@ -10,7 +10,6 @@ import juice from '@vituum/vite-plugin-juice'
|
|
10
10
|
import send from '@vituum/vite-plugin-send'
|
11
11
|
import tailwindcss from '@vituum/vite-plugin-tailwindcss'
|
12
12
|
import { getPackageInfo, merge } from 'vituum/utils/common.js'
|
13
|
-
import parseMinifyHtml from './src/minify.js'
|
14
13
|
import highlight from './src/prism.js'
|
15
14
|
import twigOptions from './src/twig.js'
|
16
15
|
import FastGlob from 'fast-glob'
|
@@ -46,6 +45,7 @@ const posthtmlPrism = {
|
|
46
45
|
const defaultOptions = {
|
47
46
|
mode: null,
|
48
47
|
cert: 'localhost',
|
48
|
+
format: ['latte'],
|
49
49
|
emails: {
|
50
50
|
outputDir: resolve(process.cwd(), 'public/email'),
|
51
51
|
appDir: resolve(process.cwd(), 'app/Templates/Emails')
|
@@ -56,6 +56,7 @@ const defaultOptions = {
|
|
56
56
|
}
|
57
57
|
},
|
58
58
|
posthtml: {
|
59
|
+
enforce: 'pre',
|
59
60
|
root: resolve(process.cwd(), 'src')
|
60
61
|
},
|
61
62
|
juice: {
|
@@ -79,9 +80,7 @@ const defaultOptions = {
|
|
79
80
|
}
|
80
81
|
},
|
81
82
|
filters: {
|
82
|
-
json:
|
83
|
-
return await parseMinifyHtml(input, name)
|
84
|
-
},
|
83
|
+
json: resolve(process.cwd(), 'node_modules/@newlogic-digital/core/latte/JsonFilter.js'),
|
85
84
|
code: 'node_modules/@newlogic-digital/core/latte/CodeFilter.php'
|
86
85
|
},
|
87
86
|
ignoredPaths: ['**/views/email/**/!(*.test).latte', '**/emails/!(*.test).latte']
|
@@ -96,12 +95,21 @@ const defaultOptions = {
|
|
96
95
|
const plugin = (options = {}) => {
|
97
96
|
options = merge(defaultOptions, options)
|
98
97
|
|
98
|
+
const templatesPlugins = []
|
99
|
+
|
100
|
+
if (options.format.includes('twig')) {
|
101
|
+
templatesPlugins.push(twig(options.twig))
|
102
|
+
}
|
103
|
+
|
104
|
+
if (options.format.includes('latte')) {
|
105
|
+
templatesPlugins.push(latte(options.latte))
|
106
|
+
}
|
107
|
+
|
99
108
|
const plugins = [
|
100
109
|
vituum(options.vituum),
|
101
110
|
tailwindcss(options.tailwindcss),
|
102
111
|
posthtml(options.posthtml),
|
103
|
-
|
104
|
-
twig(options.twig),
|
112
|
+
...templatesPlugins,
|
105
113
|
juice(options.juice),
|
106
114
|
send(options.send),
|
107
115
|
posthtmlPrism
|
@@ -117,23 +125,23 @@ const plugin = (options = {}) => {
|
|
117
125
|
|
118
126
|
let defaultInput = [
|
119
127
|
'./src/styles/*.{css,pcss,scss,sass,less,styl,stylus}',
|
120
|
-
'./src/scripts/*.{js,ts,mjs}'
|
121
|
-
'./src/views/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
|
122
|
-
'!./src/views/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json'
|
128
|
+
'./src/scripts/*.{js,ts,mjs}'
|
123
129
|
]
|
124
130
|
|
125
131
|
if (!options.mode) {
|
126
132
|
options.mode = userEnv.mode
|
127
133
|
}
|
128
134
|
|
129
|
-
if (
|
130
|
-
userEnv.mode = 'production'
|
131
|
-
|
135
|
+
if (options.mode === 'development') {
|
132
136
|
defaultInput = [
|
137
|
+
'./src/views/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
|
138
|
+
'!./src/views/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json',
|
133
139
|
'./src/styles/*.{css,pcss,scss,sass,less,styl,stylus}',
|
134
140
|
'./src/scripts/*.{js,ts,mjs}'
|
135
141
|
]
|
136
|
-
}
|
142
|
+
}
|
143
|
+
|
144
|
+
if (options.mode === 'emails') {
|
137
145
|
userEnv.mode = 'production'
|
138
146
|
|
139
147
|
defaultInput = [
|
@@ -142,12 +150,18 @@ const plugin = (options = {}) => {
|
|
142
150
|
]
|
143
151
|
}
|
144
152
|
|
153
|
+
const outDir = resolve(userConfig.root ?? process.cwd(), 'public')
|
154
|
+
|
155
|
+
if (userConfig.build && !userConfig.build.outDir) {
|
156
|
+
userConfig.build.outDir = outDir
|
157
|
+
}
|
158
|
+
|
145
159
|
userConfig.build = Object.assign({
|
146
160
|
manifest: true,
|
147
161
|
emptyOutDir: false,
|
148
162
|
modulePreload: false,
|
149
163
|
assetsInlineLimit: 0,
|
150
|
-
outDir
|
164
|
+
outDir,
|
151
165
|
rollupOptions: {
|
152
166
|
input: defaultInput
|
153
167
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@newlogic-digital/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.0.0-
|
4
|
+
"version": "2.0.0-beta.1",
|
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",
|
@@ -11,13 +11,13 @@
|
|
11
11
|
"eslint": "eslint '**/*.js' --fix"
|
12
12
|
},
|
13
13
|
"dependencies": {
|
14
|
-
"@vituum/vite-plugin-posthtml": "^1.0.0-
|
15
|
-
"@vituum/vite-plugin-juice": "^1.0.0-
|
16
|
-
"@vituum/vite-plugin-latte": "^1.0.0-
|
17
|
-
"@vituum/vite-plugin-twig": "^1.0.0-
|
18
|
-
"@vituum/vite-plugin-tailwindcss": "^1.0.0-
|
19
|
-
"@vituum/vite-plugin-send": "^1.0.0-
|
20
|
-
"vituum": "^1.0.0-
|
14
|
+
"@vituum/vite-plugin-posthtml": "^1.0.0-beta.1",
|
15
|
+
"@vituum/vite-plugin-juice": "^1.0.0-beta.1",
|
16
|
+
"@vituum/vite-plugin-latte": "^1.0.0-beta.1",
|
17
|
+
"@vituum/vite-plugin-twig": "^1.0.0-beta.1",
|
18
|
+
"@vituum/vite-plugin-tailwindcss": "^1.0.0-beta.1",
|
19
|
+
"@vituum/vite-plugin-send": "^1.0.0-beta.1",
|
20
|
+
"vituum": "^1.0.0-beta.3",
|
21
21
|
"posthtml": "^0.16.6",
|
22
22
|
"posthtml-prism": "^2.0.0",
|
23
23
|
"prismjs": "^1.29.0",
|
@@ -36,9 +36,14 @@
|
|
36
36
|
},
|
37
37
|
"files": [
|
38
38
|
"latte",
|
39
|
+
"types",
|
39
40
|
"index.js",
|
40
41
|
"src"
|
41
42
|
],
|
43
|
+
"exports": {
|
44
|
+
".": "./index.js",
|
45
|
+
"./types": "./types/*"
|
46
|
+
},
|
42
47
|
"engines": {
|
43
48
|
"node": ">=16.0.0",
|
44
49
|
"npm": ">=8.0.0"
|
package/types/index.d.ts
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
interface Emails {
|
2
|
+
outputDir?: string
|
3
|
+
appDir?: string
|
4
|
+
}
|
5
|
+
|
6
|
+
export interface PluginUserConfig {
|
7
|
+
mode?: string
|
8
|
+
format?: string[]
|
9
|
+
cert?: string
|
10
|
+
emails?: Emails
|
11
|
+
vituum?: import('vituum/types').UserConfig,
|
12
|
+
posthtml?: import('@vituum/vite-plugin-posthtml/types').PluginUserConfig
|
13
|
+
juice?: import('@vituum/vite-plugin-juice/types').PluginUserConfig
|
14
|
+
send?: import('@vituum/vite-plugin-send/types').PluginUserConfig
|
15
|
+
tailwindcss?: import('@vituum/vite-plugin-tailwindcss/types').PluginUserConfig
|
16
|
+
latte?: import('@vituum/vite-plugin-latte/types').PluginUserConfig
|
17
|
+
twig?: import('@vituum/vite-plugin-twig/types').PluginUserConfig
|
18
|
+
}
|