@vituum/vite-plugin-latte 1.0.0-alpha.1 → 1.0.0-alpha.3
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/index.js +4 -4
- package/package.json +7 -2
- package/types/index.d.ts +13 -0
package/index.js
CHANGED
|
@@ -40,8 +40,8 @@ const execSync = (cmd) => {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const renderTemplate = ({ path, filename, cwd, packageRoot }, params, content) => {
|
|
44
|
-
const renderTransformedHtml = params.renderTransformedHtml(filename)
|
|
43
|
+
const renderTemplate = ({ server, path, filename, cwd, packageRoot }, params, content) => {
|
|
44
|
+
const renderTransformedHtml = params.renderTransformedHtml(server ? filename.replace('.html', '') : filename)
|
|
45
45
|
|
|
46
46
|
if (params.data) {
|
|
47
47
|
const normalizePaths = Array.isArray(params.data) ? params.data.map(path => path.replace(/\\/g, '/')) : params.data.replace(/\\/g, '/')
|
|
@@ -73,7 +73,7 @@ const renderTemplate = ({ path, filename, cwd, packageRoot }, params, content) =
|
|
|
73
73
|
fs.writeFileSync(resolve(packageRoot, `temp/${timestamp}.html`), content)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
return execSync(`${params.bin} ${packageRoot}/index.php ${join(params.root, path)} ${JSON.stringify(JSON.stringify(Object.assign({ packageRoot, cwd, renderTransformedHtml }, params)))}`)
|
|
76
|
+
return execSync(`${params.bin} ${packageRoot}/index.php ${join(params.root, server ? path.replace('.html', '') : path)} ${JSON.stringify(JSON.stringify(Object.assign({ packageRoot, cwd, renderTransformedHtml }, params)))}`)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -138,7 +138,7 @@ const plugin = (options = {}) => {
|
|
|
138
138
|
return content
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const render = renderTemplate({ path, filename, cwd, packageRoot }, options, content)
|
|
141
|
+
const render = renderTemplate({ server, path, filename, cwd, packageRoot }, options, content)
|
|
142
142
|
const warningLog = render.output.includes('Warning: Undefined')
|
|
143
143
|
|
|
144
144
|
if (render.error || warningLog) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vituum/vite-plugin-latte",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,8 +26,13 @@
|
|
|
26
26
|
"handler.js",
|
|
27
27
|
"index.php",
|
|
28
28
|
"latte",
|
|
29
|
-
"vendor"
|
|
29
|
+
"vendor",
|
|
30
|
+
"types"
|
|
30
31
|
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./index.js",
|
|
34
|
+
"./types": "./types/*"
|
|
35
|
+
},
|
|
31
36
|
"engines": {
|
|
32
37
|
"node": ">=16.0.0",
|
|
33
38
|
"npm": ">=8.0.0"
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PluginUserConfig {
|
|
2
|
+
reload?: boolean | Function
|
|
3
|
+
root?: string
|
|
4
|
+
filters?: Object
|
|
5
|
+
functions?: Object
|
|
6
|
+
tags?: Object
|
|
7
|
+
globals?: Object
|
|
8
|
+
data?: string | string[]
|
|
9
|
+
formats?: string[]
|
|
10
|
+
bin?: string
|
|
11
|
+
renderTransformedHtml?: (filename: string) => boolean
|
|
12
|
+
ignoredPaths?: string[]
|
|
13
|
+
}
|