@plaudit/webpack-extensions 2.21.1 → 2.21.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.
|
@@ -102,67 +102,74 @@ class BlockJSONManagingPlugin {
|
|
|
102
102
|
else {
|
|
103
103
|
json["version"] = BlockJSONManagingPlugin.hashThingForAsset(compositeHash);
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
const pathsNeedRemapping = !this.standaloneBlocks && json["plaudit"] !== "simple";
|
|
106
|
+
const { assetSourceFiles } = sourceFileMappers();
|
|
107
|
+
const sourceDir = node_path_1.default.join(compiler.context, node_path_1.default.dirname(assetSourceFiles.get(name) ?? name));
|
|
108
|
+
const outputDir = node_path_1.default.join(compiler.outputPath, node_path_1.default.dirname(name));
|
|
109
|
+
const stripFilePrefix = (file) => file.startsWith("file:./") ? file.substring(7) : file;
|
|
110
|
+
const rawSetupFiles = json["plaudit"]?.["setup"]
|
|
111
|
+
? (typeof json["plaudit"]["setup"] === 'string' ? [json["plaudit"]["setup"]] : json["plaudit"]["setup"])
|
|
112
|
+
: ["setup.php"];
|
|
113
|
+
const setupFiles = pathsNeedRemapping
|
|
114
|
+
? rawSetupFiles
|
|
113
115
|
.map(p => node_path_1.default.normalize(node_path_1.default.join(sourceDir, stripFilePrefix(p))))
|
|
114
116
|
.filter(p => node_fs_1.default.existsSync(p))
|
|
115
|
-
.map(p => `file:./${this.findRelativeRouteBetween(outputDir, p)}`)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
else {
|
|
122
|
-
if (typeof json["plaudit"] !== 'object') {
|
|
123
|
-
if (json["plaudit"] === "native") {
|
|
124
|
-
json["plaudit"] = { type: "native" };
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
json["plaudit"] = {};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
json["plaudit"]["setup"] = setupFiles.length === 1 ? setupFiles[0] : setupFiles;
|
|
117
|
+
.map(p => `file:./${this.findRelativeRouteBetween(outputDir, p)}`)
|
|
118
|
+
: rawSetupFiles
|
|
119
|
+
.filter(p => node_fs_1.default.existsSync(node_path_1.default.normalize(node_path_1.default.join(sourceDir, stripFilePrefix(p)))));
|
|
120
|
+
if (setupFiles.length === 0) {
|
|
121
|
+
if (json["plaudit"]?.["setup"] !== undefined) {
|
|
122
|
+
delete json["plaudit"]["setup"];
|
|
131
123
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
if (typeof json["plaudit"] !== 'object') {
|
|
127
|
+
if (json["plaudit"] === "native") {
|
|
128
|
+
json["plaudit"] = { type: "native" };
|
|
136
129
|
}
|
|
137
|
-
else
|
|
138
|
-
json["
|
|
139
|
-
delete json["acf"]["render_template"];
|
|
130
|
+
else {
|
|
131
|
+
json["plaudit"] = {};
|
|
140
132
|
}
|
|
141
133
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
json["plaudit"]["setup"] = setupFiles.length === 1 ? setupFiles[0] : setupFiles;
|
|
135
|
+
}
|
|
136
|
+
if (json["acf"]) {
|
|
137
|
+
if (json["acf"]["renderTemplate"]) {
|
|
138
|
+
json["render_template"] = json["acf"]["renderTemplate"];
|
|
139
|
+
delete json["acf"]["renderTemplate"];
|
|
140
|
+
}
|
|
141
|
+
else if (json["acf"]["render_template"]) {
|
|
142
|
+
json["render_template"] = json["acf"]["render_template"];
|
|
143
|
+
delete json["acf"]["render_template"];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
let rawRenderTemplate = json["render"] ?? json["render_template"];
|
|
147
|
+
rawRenderTemplate = (rawRenderTemplate
|
|
148
|
+
? (typeof rawRenderTemplate === 'string' ? [rawRenderTemplate] : rawRenderTemplate)
|
|
149
|
+
: ["template.php", "template.twig"]);
|
|
150
|
+
const renderTemplate = pathsNeedRemapping
|
|
151
|
+
? rawRenderTemplate
|
|
146
152
|
.map(p => node_path_1.default.normalize(node_path_1.default.join(sourceDir, stripFilePrefix(p))))
|
|
147
153
|
.filter(p => node_fs_1.default.existsSync(p))
|
|
148
|
-
.map(p => `file:./${this.findRelativeRouteBetween(outputDir, p)}`)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
.map(p => `file:./${this.findRelativeRouteBetween(outputDir, p)}`)
|
|
155
|
+
: rawRenderTemplate
|
|
156
|
+
.filter(p => node_fs_1.default.existsSync(node_path_1.default.normalize(node_path_1.default.join(sourceDir, stripFilePrefix(p)))));
|
|
157
|
+
if (renderTemplate.length === 0) {
|
|
158
|
+
delete json["render_template"];
|
|
159
|
+
delete json["render"];
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
let validTemplateLocation, invalidTemplateLocation;
|
|
163
|
+
if (!json["acf"] && (json["plaudit"] === "native" || (typeof json["plaudit"] === 'object' && json["plaudit"]?.["type"] === "native"))) {
|
|
164
|
+
validTemplateLocation = "render";
|
|
165
|
+
invalidTemplateLocation = "render_template";
|
|
152
166
|
}
|
|
153
167
|
else {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
validTemplateLocation = "render";
|
|
157
|
-
invalidTemplateLocation = "render_template";
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
validTemplateLocation = "render_template";
|
|
161
|
-
invalidTemplateLocation = "render";
|
|
162
|
-
}
|
|
163
|
-
delete json[invalidTemplateLocation];
|
|
164
|
-
json[validTemplateLocation] = renderTemplate.length === 1 ? renderTemplate[0] : renderTemplate;
|
|
168
|
+
validTemplateLocation = "render_template";
|
|
169
|
+
invalidTemplateLocation = "render";
|
|
165
170
|
}
|
|
171
|
+
delete json[invalidTemplateLocation];
|
|
172
|
+
json[validTemplateLocation] = renderTemplate.length === 1 ? renderTemplate[0] : renderTemplate;
|
|
166
173
|
}
|
|
167
174
|
compilation.updateAsset(name, new webpack_1.sources.RawSource(JSON.stringify(json, undefined, " ")));
|
|
168
175
|
}
|
|
@@ -195,6 +202,7 @@ class BlockJSONManagingPlugin {
|
|
|
195
202
|
static resolveFilesFromStats(compilationAssets, stats) {
|
|
196
203
|
const singleFileChunkToOutputName = new Map(stats.assets
|
|
197
204
|
.filter((asset) => asset.chunks?.length === 1)
|
|
205
|
+
.filter(asset => !asset.name.endsWith("-rtl.css"))
|
|
198
206
|
.filter(asset => !asset.name.endsWith('.asset.php'))
|
|
199
207
|
.map(asset => {
|
|
200
208
|
let assetHash = asset.info.contenthash ?? asset.info.fullhash;
|