@atomicsmash/compiler 1.0.1-beta.0 → 1.1.0-beta.2
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/config.d.ts +2 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +59 -16
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import webpack from "webpack";
|
|
|
9
9
|
import { WebpackAssetsManifest } from "webpack-assets-manifest";
|
|
10
10
|
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
|
|
11
11
|
import { BlocksPlugin } from "./BlocksPlugin.js";
|
|
12
|
+
import { SCSSAliases } from "./index.js";
|
|
12
13
|
export declare function config(options: {
|
|
13
14
|
/**
|
|
14
15
|
* The directory where the source files can be found. Relative to cwd.
|
|
@@ -110,11 +111,7 @@ export declare function config(options: {
|
|
|
110
111
|
loader: string;
|
|
111
112
|
options: {
|
|
112
113
|
sourceMap: boolean;
|
|
113
|
-
sassOptions:
|
|
114
|
-
importers: {
|
|
115
|
-
findFileUrl(url: string): import("url").URL | null;
|
|
116
|
-
}[];
|
|
117
|
-
};
|
|
114
|
+
sassOptions: SCSSAliases;
|
|
118
115
|
postcssOptions?: undefined;
|
|
119
116
|
};
|
|
120
117
|
})[];
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,QAAQ,EAAe,MAAM,SAAS,CAAC;AAQpE,OAAO,iCAAiC,MAAM,iDAAiD,CAAC;AAEhG,OAAO,UAAU,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,QAAQ,EAAe,MAAM,SAAS,CAAC;AAQpE,OAAO,iCAAiC,MAAM,iDAAiD,CAAC;AAEhG,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,kBAAkB,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAsB,MAAM,CAAC,OAAO,EAAE;IACrC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA6K6B,QAAQ;;;;;;;;;;;qCAeX,QAAQ;;;;;;;;;;sCA1OrB,CAAC;;;;;;;;;;;;;;;;;;;;;GAyad"}
|
package/dist/config.js
CHANGED
|
@@ -3,6 +3,7 @@ import { pathToFileURL } from "node:url";
|
|
|
3
3
|
import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
|
|
4
4
|
import browserslistToEsbuild from "browserslist-to-esbuild";
|
|
5
5
|
import CopyPlugin from "copy-webpack-plugin";
|
|
6
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
6
7
|
import cssNano from "cssnano";
|
|
7
8
|
import { EsbuildPlugin } from "esbuild-loader";
|
|
8
9
|
import glob from "fast-glob";
|
|
@@ -225,18 +226,7 @@ export async function config(options) {
|
|
|
225
226
|
loader: "sass-loader",
|
|
226
227
|
options: {
|
|
227
228
|
sourceMap: MODE === "development",
|
|
228
|
-
sassOptions:
|
|
229
|
-
importers: [
|
|
230
|
-
{
|
|
231
|
-
findFileUrl(url) {
|
|
232
|
-
if (!url.startsWith("sitecss:"))
|
|
233
|
-
return null;
|
|
234
|
-
const pathname = url.substring(8);
|
|
235
|
-
return pathToFileURL(`${srcFolder}/styles${pathname.startsWith("/") ? pathname : `/${pathname}`}`);
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
],
|
|
239
|
-
},
|
|
229
|
+
sassOptions: await getSassOptions(srcFolder),
|
|
240
230
|
},
|
|
241
231
|
},
|
|
242
232
|
],
|
|
@@ -319,10 +309,14 @@ export async function config(options) {
|
|
|
319
309
|
},
|
|
320
310
|
}),
|
|
321
311
|
// Create an SVG sprite from a folder of provided icons
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
312
|
+
...((await glob(`${srcFolder}/icons/*.svg`)).length
|
|
313
|
+
? [
|
|
314
|
+
new SVGSpritemapPlugin(`${srcFolder}/icons/*.svg`, {
|
|
315
|
+
output: { filename: "icons/sprite.svg" },
|
|
316
|
+
sprite: { prefix: "", generate: { title: false } },
|
|
317
|
+
}),
|
|
318
|
+
]
|
|
319
|
+
: []),
|
|
326
320
|
// Copy fonts and images from the src folder to assets (available for backwards compatibility, not recommended)
|
|
327
321
|
new CopyPlugin({
|
|
328
322
|
patterns: [
|
|
@@ -373,3 +367,52 @@ export async function config(options) {
|
|
|
373
367
|
},
|
|
374
368
|
};
|
|
375
369
|
}
|
|
370
|
+
async function getSassOptions(srcFolder) {
|
|
371
|
+
const explorer = cosmiconfig("scssAliases");
|
|
372
|
+
const config = await explorer
|
|
373
|
+
.load(resolvePath(process.cwd(), "scssAliases.config.ts"))
|
|
374
|
+
.then((result) => {
|
|
375
|
+
if (!result || result.isEmpty) {
|
|
376
|
+
throw new Error("Return default config.");
|
|
377
|
+
}
|
|
378
|
+
const config = result.config;
|
|
379
|
+
if (typeof config === "object" &&
|
|
380
|
+
config !== null &&
|
|
381
|
+
Object.keys(config).length <= 2) {
|
|
382
|
+
if (Object.keys(config).length === 2 &&
|
|
383
|
+
"importers" in config &&
|
|
384
|
+
"loadPaths" in config) {
|
|
385
|
+
return config;
|
|
386
|
+
}
|
|
387
|
+
if (Object.keys(config).length === 1 &&
|
|
388
|
+
("importers" in config || "loadPaths" in config)) {
|
|
389
|
+
return config;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
throw new Error("Return default config.");
|
|
393
|
+
})
|
|
394
|
+
.catch(() => {
|
|
395
|
+
const defaultConfig = {
|
|
396
|
+
importers: [
|
|
397
|
+
{
|
|
398
|
+
findFileUrl(url) {
|
|
399
|
+
if (!url.startsWith("sitecss:"))
|
|
400
|
+
return null;
|
|
401
|
+
const pathname = url.substring(8);
|
|
402
|
+
return pathToFileURL(`${resolvePath(srcFolder, "../css")}${pathname.startsWith("/") ? pathname : `/${pathname}`}`);
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
findFileUrl(url) {
|
|
407
|
+
if (!url.startsWith("launchpad:"))
|
|
408
|
+
return null;
|
|
409
|
+
const pathname = url.substring(10);
|
|
410
|
+
return pathToFileURL(`${resolvePath(process.cwd(), "public/wp-content/themes/launchpad/src/styles")}${pathname.startsWith("/") ? pathname : `/${pathname}`}`);
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
],
|
|
414
|
+
};
|
|
415
|
+
return defaultConfig;
|
|
416
|
+
});
|
|
417
|
+
return config;
|
|
418
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,MAAM,MAAM,WAAW,GAAG;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;CAC1C,CAAC"}
|
package/dist/index.js
CHANGED