@vituum/vite-plugin-pug 0.1.2 → 0.1.4
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 +9 -6
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -40,15 +40,18 @@ const renderTemplate = async(filename, content, options) => {
|
|
|
40
40
|
const context = options.data ? processData(options.data, options.globals) : options.globals
|
|
41
41
|
|
|
42
42
|
const isJson = filename.endsWith('.json.html') || filename.endsWith('.json')
|
|
43
|
-
const isHtml = filename.endsWith('.html') && !
|
|
43
|
+
const isHtml = filename.endsWith('.html') && !options.filetypes.html.test(filename) && !options.filetypes.json.test(filename) && !isJson
|
|
44
44
|
|
|
45
45
|
if (isJson || isHtml) {
|
|
46
46
|
lodash.merge(context, isHtml ? content : JSON.parse(fs.readFileSync(filename).toString()))
|
|
47
47
|
|
|
48
48
|
output.template = true
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (typeof context.template === 'undefined') {
|
|
51
|
+
console.error(chalk.red(name + ' template must be defined - ' + filename))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
context.template = relative(process.cwd(), context.template).startsWith(relative(process.cwd(), options.root)) ? resolve(process.cwd(), context.template) : resolve(options.root, context.template)
|
|
52
55
|
} else if (fs.existsSync(filename + '.json')) {
|
|
53
56
|
lodash.merge(context, JSON.parse(fs.readFileSync(filename + '.json').toString()))
|
|
54
57
|
}
|
|
@@ -60,7 +63,7 @@ const renderTemplate = async(filename, content, options) => {
|
|
|
60
63
|
}))
|
|
61
64
|
|
|
62
65
|
output.content = template(context)
|
|
63
|
-
} catch(error) {
|
|
66
|
+
} catch (error) {
|
|
64
67
|
output.error = error
|
|
65
68
|
}
|
|
66
69
|
|
|
@@ -107,13 +110,13 @@ const plugin = (options = {}) => {
|
|
|
107
110
|
return
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
server.ws.send({
|
|
113
|
+
setTimeout(() => server.ws.send({
|
|
111
114
|
type: 'error',
|
|
112
115
|
err: {
|
|
113
116
|
message: render.error.message,
|
|
114
117
|
plugin: name
|
|
115
118
|
}
|
|
116
|
-
})
|
|
119
|
+
}), 50)
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
return render.content
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vituum/vite-plugin-pug",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"pug": "^3.0.2",
|
|
8
8
|
"lodash": "^4.17.21",
|
|
9
|
-
"chalk": "^5.0
|
|
10
|
-
"fast-glob": "^3.2.
|
|
9
|
+
"chalk": "^5.2.0",
|
|
10
|
+
"fast-glob": "^3.2.12"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"eslint": "^8.
|
|
13
|
+
"eslint": "^8.29.0",
|
|
14
14
|
"eslint-config-standard": "^17.0.0"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|