@ixon-cdk/svelte-builder 1.0.0-alpha.2 → 1.0.0-alpha.6
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/browser.js +14 -19
- package/index.js +2 -1
- package/package.json +4 -4
package/browser.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
|
-
const
|
|
4
|
-
const { build } = require("vite");
|
|
3
|
+
const { build, normalizePath } = require("vite");
|
|
5
4
|
const { svelte } = require("@sveltejs/vite-plugin-svelte");
|
|
6
5
|
const preprocess = require("svelte-preprocess");
|
|
7
6
|
const {
|
|
8
7
|
getRootDir,
|
|
9
|
-
copyMetaFiles,
|
|
10
8
|
pascalCase,
|
|
9
|
+
cleanDir,
|
|
11
10
|
watchInputDir,
|
|
12
11
|
writeDemoFile,
|
|
12
|
+
copyAssets,
|
|
13
|
+
watchAssets,
|
|
13
14
|
} = require("@ixon-cdk/core");
|
|
14
15
|
|
|
15
|
-
async function _build(inputFile, outputFile, tag, production, watch) {
|
|
16
|
+
async function _build(inputFile, outputFile, tag, assets, production, watch) {
|
|
16
17
|
const inputDir = path.dirname(path.join(getRootDir(), inputFile));
|
|
17
18
|
const outputDir = path.dirname(path.join(getRootDir(), outputFile));
|
|
18
19
|
|
|
@@ -23,21 +24,13 @@ async function _build(inputFile, outputFile, tag, production, watch) {
|
|
|
23
24
|
path.dirname(entryFileName),
|
|
24
25
|
path.join(getRootDir(), inputFile)
|
|
25
26
|
);
|
|
26
|
-
const entryFileContent = `import ${componentStatic} from '${relativeInputPath}';\nexport default new ${componentStatic}();\n`;
|
|
27
|
+
const entryFileContent = `import ${componentStatic} from '${normalizePath(relativeInputPath)}';\nexport default new ${componentStatic}();\n`;
|
|
27
28
|
fs.writeFileSync(entryFileName, entryFileContent, {
|
|
28
29
|
encoding: "utf8",
|
|
29
30
|
flag: "w",
|
|
30
31
|
});
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
if (fs.existsSync(outputDir)) {
|
|
34
|
-
rimraf.sync(outputDir);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// output folder
|
|
38
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
39
|
-
|
|
40
|
-
// demo file
|
|
33
|
+
cleanDir(outputDir);
|
|
41
34
|
writeDemoFile(tag, outputDir, outputFile);
|
|
42
35
|
|
|
43
36
|
const config = {
|
|
@@ -75,13 +68,14 @@ async function _build(inputFile, outputFile, tag, production, watch) {
|
|
|
75
68
|
|
|
76
69
|
// build
|
|
77
70
|
await build(config);
|
|
78
|
-
|
|
71
|
+
copyAssets(assets, inputDir, outputDir);
|
|
79
72
|
|
|
80
73
|
// watch source files
|
|
81
74
|
if (watch) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
watchAssets(assets, inputDir, outputDir);
|
|
76
|
+
await watchInputDir(inputDir, (isAsset) => {
|
|
77
|
+
if (isAsset) {
|
|
78
|
+
// do nothing
|
|
85
79
|
} else {
|
|
86
80
|
build(config);
|
|
87
81
|
}
|
|
@@ -97,8 +91,9 @@ module.exports = function runBuild(
|
|
|
97
91
|
inputFile,
|
|
98
92
|
outputFile,
|
|
99
93
|
tag,
|
|
94
|
+
assets,
|
|
100
95
|
production = true,
|
|
101
96
|
watch = false
|
|
102
97
|
) {
|
|
103
|
-
return _build(inputFile, outputFile, tag, production, watch);
|
|
98
|
+
return _build(inputFile, outputFile, tag, assets, production, watch);
|
|
104
99
|
};
|
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ function main() {
|
|
|
13
13
|
const tag = argv._[1];
|
|
14
14
|
const input = argv.input;
|
|
15
15
|
const output = argv.output || "dist/bundle/main.min.js";
|
|
16
|
+
const assets = JSON.parse(argv.assets || "[]");
|
|
16
17
|
const watch = !!argv.watch;
|
|
17
18
|
|
|
18
19
|
if (!input) {
|
|
@@ -35,7 +36,7 @@ function main() {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
if (buildTarget === "browser") {
|
|
38
|
-
require("./browser")(input, output, tag, true, watch);
|
|
39
|
+
require("./browser")(input, output, tag, assets, true, watch);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixon-cdk/svelte-builder",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
|
|
10
10
|
"is-potential-custom-element-name": "^1.0.1",
|
|
11
|
-
"rimraf": "^3.0.2",
|
|
12
11
|
"sass": "^1.43.4",
|
|
13
12
|
"svelte": "^3.44.0",
|
|
14
|
-
"svelte-preprocess": "^4.9.8"
|
|
13
|
+
"svelte-preprocess": "^4.9.8",
|
|
14
|
+
"vite": "^2.6.12"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@ixon-cdk/core": "^1.0.0-alpha.
|
|
17
|
+
"@ixon-cdk/core": "^1.0.0-alpha.6"
|
|
18
18
|
}
|
|
19
19
|
}
|