@atomicsmash/compiler 0.7.4 → 0.7.5
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/dist/index.js +66 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -65,15 +65,16 @@ const tailwindPostCSSPlugin = await import("@tailwindcss/postcss")
|
|
|
65
65
|
// Add optional support for Vue if vue-loader is installed
|
|
66
66
|
const vueConfig = await import("vue-loader")
|
|
67
67
|
.then((vueLoaderModule) => ({
|
|
68
|
-
loader: [
|
|
69
|
-
{
|
|
70
|
-
test: /\.vue$/,
|
|
71
|
-
loader: "vue-loader",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
68
|
+
loader: [{ test: /\.vue$/, loader: "vue-loader" }],
|
|
74
69
|
plugin: [new vueLoaderModule.VueLoaderPlugin()],
|
|
70
|
+
globals: {
|
|
71
|
+
__VUE_OPTIONS_API__: "true",
|
|
72
|
+
__VUE_PROD_DEVTOOLS__: "false",
|
|
73
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false",
|
|
74
|
+
},
|
|
75
|
+
aliases: { vue: "vue/dist/vue.esm-bundler.js" },
|
|
75
76
|
}))
|
|
76
|
-
.catch(() => ({ loader: [], plugin: [] }));
|
|
77
|
+
.catch(() => ({ loader: [], plugin: [], globals: {}, aliases: {} }));
|
|
77
78
|
const postCSSConfig = [
|
|
78
79
|
[
|
|
79
80
|
// Support tailwind if package is found
|
|
@@ -167,11 +168,10 @@ const compiler = webpack({
|
|
|
167
168
|
path: distFolder,
|
|
168
169
|
},
|
|
169
170
|
resolve: {
|
|
171
|
+
alias: { ...vueConfig.aliases },
|
|
170
172
|
// support TSConfig paths as aliases
|
|
171
173
|
plugins: [
|
|
172
|
-
new TsconfigPathsPlugin({
|
|
173
|
-
configFile: process.cwd() + "/tsconfig.json",
|
|
174
|
-
}),
|
|
174
|
+
new TsconfigPathsPlugin({ configFile: process.cwd() + "/tsconfig.json" }),
|
|
175
175
|
],
|
|
176
176
|
// resolve TS extensions
|
|
177
177
|
extensions: [".tsx", ".ts", ".js", ".jsx", ".vue"],
|
|
@@ -212,9 +212,31 @@ const compiler = webpack({
|
|
|
212
212
|
type: "asset/resource",
|
|
213
213
|
generator: {
|
|
214
214
|
binary: false,
|
|
215
|
-
filename: (pathData) =>
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
filename: (pathData) => {
|
|
216
|
+
const fileName = pathData.filename;
|
|
217
|
+
if (!fileName) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const isVendorFile = fileName.includes("node_modules");
|
|
221
|
+
if (isVendorFile) {
|
|
222
|
+
const vendorPathData = fileName.split(pathSeparator);
|
|
223
|
+
const nodeModulesPosition = vendorPathData.findIndex((value) => value.includes("node_modules"));
|
|
224
|
+
const vendorArray = vendorPathData.slice(nodeModulesPosition + 1, nodeModulesPosition + 3);
|
|
225
|
+
let vendor;
|
|
226
|
+
if (vendorArray[0]?.startsWith("@")) {
|
|
227
|
+
vendor = vendorArray.join(pathSeparator);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
vendor = vendorArray[0] ?? "";
|
|
231
|
+
}
|
|
232
|
+
return ["css", "vendor", vendor, vendorPathData.at(-1)]
|
|
233
|
+
.join(pathSeparator)
|
|
234
|
+
.replace(".scss", ".[contenthash].css");
|
|
235
|
+
}
|
|
236
|
+
return relative(srcFolder, pathData.filename ?? "")
|
|
237
|
+
.replace(".scss", ".[contenthash].css")
|
|
238
|
+
.replace("styles/", "css/");
|
|
239
|
+
},
|
|
218
240
|
},
|
|
219
241
|
use: [
|
|
220
242
|
{
|
|
@@ -228,9 +250,7 @@ const compiler = webpack({
|
|
|
228
250
|
},
|
|
229
251
|
{
|
|
230
252
|
loader: "sass-loader",
|
|
231
|
-
options: {
|
|
232
|
-
sourceMap: MODE === "development",
|
|
233
|
-
},
|
|
253
|
+
options: { sourceMap: MODE === "development" },
|
|
234
254
|
},
|
|
235
255
|
],
|
|
236
256
|
},
|
|
@@ -240,9 +260,31 @@ const compiler = webpack({
|
|
|
240
260
|
type: "asset/resource",
|
|
241
261
|
generator: {
|
|
242
262
|
binary: false,
|
|
243
|
-
filename: (pathData) =>
|
|
244
|
-
|
|
245
|
-
|
|
263
|
+
filename: (pathData) => {
|
|
264
|
+
const fileName = pathData.filename;
|
|
265
|
+
if (!fileName) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const isVendorFile = fileName.includes("node_modules");
|
|
269
|
+
if (isVendorFile) {
|
|
270
|
+
const vendorPathData = fileName.split(pathSeparator);
|
|
271
|
+
const nodeModulesPosition = vendorPathData.findIndex((value) => value.includes("node_modules"));
|
|
272
|
+
const vendorArray = vendorPathData.slice(nodeModulesPosition + 1, nodeModulesPosition + 3);
|
|
273
|
+
let vendor;
|
|
274
|
+
if (vendorArray[0]?.startsWith("@")) {
|
|
275
|
+
vendor = vendorArray.join(pathSeparator);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
vendor = vendorArray[0] ?? "";
|
|
279
|
+
}
|
|
280
|
+
return ["css", "vendor", vendor, vendorPathData.at(-1)]
|
|
281
|
+
.join(pathSeparator)
|
|
282
|
+
.replace(".css", ".[contenthash].css");
|
|
283
|
+
}
|
|
284
|
+
return relative(srcFolder, pathData.filename ?? "")
|
|
285
|
+
.replace(".css", ".[contenthash].css")
|
|
286
|
+
.replace("styles/", "css/");
|
|
287
|
+
},
|
|
246
288
|
},
|
|
247
289
|
use: [
|
|
248
290
|
{
|
|
@@ -271,6 +313,7 @@ const compiler = webpack({
|
|
|
271
313
|
}
|
|
272
314
|
if (entry.key === "assets.php" ||
|
|
273
315
|
entry.key === "wordpress-assets-info.php" ||
|
|
316
|
+
entry.key.endsWith(".map") ||
|
|
274
317
|
entry.key.startsWith("fonts") ||
|
|
275
318
|
entry.key.startsWith("images")) {
|
|
276
319
|
return false;
|
|
@@ -292,15 +335,8 @@ const compiler = webpack({
|
|
|
292
335
|
}),
|
|
293
336
|
// Create an SVG sprite from a folder of provided icons
|
|
294
337
|
new SVGSpritemapPlugin(`${srcFolder}/icons/*.svg`, {
|
|
295
|
-
output: {
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
sprite: {
|
|
299
|
-
prefix: "",
|
|
300
|
-
generate: {
|
|
301
|
-
title: false,
|
|
302
|
-
},
|
|
303
|
-
},
|
|
338
|
+
output: { filename: "icons/sprite.[contenthash].svg" },
|
|
339
|
+
sprite: { prefix: "", generate: { title: false } },
|
|
304
340
|
}),
|
|
305
341
|
// Copy fonts and images from the src folder to assets (available for backwards compatibility, not recommended)
|
|
306
342
|
new CopyPlugin({
|
|
@@ -342,13 +378,12 @@ const compiler = webpack({
|
|
|
342
378
|
// Support Vue files if vue-loader is present
|
|
343
379
|
...vueConfig.plugin,
|
|
344
380
|
...(argv.experimentalBlocksSupport ? [new BlocksPlugin(srcFolder)] : []),
|
|
381
|
+
new webpack.DefinePlugin({ ...vueConfig.globals }),
|
|
345
382
|
],
|
|
346
383
|
optimization: {
|
|
347
384
|
minimizer: [
|
|
348
385
|
// Minify JS files
|
|
349
|
-
new EsbuildPlugin({
|
|
350
|
-
target: browserslistToEsbuild(),
|
|
351
|
-
}),
|
|
386
|
+
new EsbuildPlugin({ target: browserslistToEsbuild() }),
|
|
352
387
|
],
|
|
353
388
|
},
|
|
354
389
|
});
|