x4js 2.3.2 → 2.3.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/cli/build-options.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url";
|
|
|
3
3
|
import { sassPlugin } from "esbuild-sass-plugin";
|
|
4
4
|
import { lessPlugin } from "./less-plugin.mjs";
|
|
5
5
|
import { copyPlugin } from "./copy-plugin.mjs";
|
|
6
|
+
import { rawFilePlugin } from "./rawfile-plugin.mjs";
|
|
6
7
|
|
|
7
8
|
const cliDir = path.dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const devClient = path.join(cliDir, "dev-client.js");
|
|
@@ -28,7 +29,7 @@ export function createBuildOptions(config, mode) {
|
|
|
28
29
|
format: "iife",
|
|
29
30
|
target: "es2020",
|
|
30
31
|
minify: production,
|
|
31
|
-
sourcemap: production ? false : "
|
|
32
|
+
sourcemap: production ? false : "linked",
|
|
32
33
|
logLevel: "info",
|
|
33
34
|
external: config.external,
|
|
34
35
|
assetNames: "assets/[name]-[hash]",
|
|
@@ -47,6 +48,10 @@ export function createBuildOptions(config, mode) {
|
|
|
47
48
|
VERSION_ID: versionId(),
|
|
48
49
|
},
|
|
49
50
|
plugins: [
|
|
51
|
+
rawFilePlugin({
|
|
52
|
+
filter: /\.svg$/,
|
|
53
|
+
mime: "image/svg+xml",
|
|
54
|
+
}),
|
|
50
55
|
sassPlugin({
|
|
51
56
|
type: "css",
|
|
52
57
|
filter: /\.s[ac]ss$/,
|
package/cli/config.mjs
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export function rawFilePlugin({ filter, mime }) {
|
|
5
|
+
const namespace = "x4-raw-file";
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
name: "x4-raw-file",
|
|
9
|
+
|
|
10
|
+
setup(build) {
|
|
11
|
+
build.onResolve({ filter }, (args) => {
|
|
12
|
+
// Seulement les imports JS/TS.
|
|
13
|
+
if (
|
|
14
|
+
args.kind !== "import-statement" &&
|
|
15
|
+
args.kind !== "dynamic-import"
|
|
16
|
+
) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
path: path.resolve(args.resolveDir, args.path),
|
|
22
|
+
namespace,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
build.onLoad(
|
|
27
|
+
{ filter: /.*/, namespace },
|
|
28
|
+
async (args) => {
|
|
29
|
+
const data = await fs.readFile(args.path);
|
|
30
|
+
|
|
31
|
+
const value =
|
|
32
|
+
`data:${mime};base64,${data.toString("base64")}`;
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
contents:
|
|
36
|
+
`export default ${JSON.stringify(value)};`,
|
|
37
|
+
loader: "js",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
package/package.json
CHANGED