@ixon-cdk/static-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/README.md +2 -2
- package/browser.js +45 -61
- package/index.js +2 -1
- package/package.json +3 -7
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# IXON Component Development Kit
|
|
1
|
+
# IXON Component Development Kit Static Builder
|
|
2
2
|
|
|
3
|
-
This builder can be used with the IXON Component Development Kit (CDK). It contains build targets for building [webcomponents](https://developer.mozilla.org/en-US/docs/Web/Web_Components) (reusable custom elements) using [
|
|
3
|
+
This builder can be used with the IXON Component Development Kit (CDK). It contains build targets for building [webcomponents](https://developer.mozilla.org/en-US/docs/Web/Web_Components) (reusable custom elements) using [Vite](https://vitejs.dev/).
|
package/browser.js
CHANGED
|
@@ -1,77 +1,60 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const rollup = require("rollup");
|
|
3
|
-
const commonjs = require("@rollup/plugin-commonjs");
|
|
4
|
-
const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
|
5
|
-
const { terser } = require("rollup-plugin-terser");
|
|
6
1
|
const path = require("path");
|
|
7
|
-
const
|
|
2
|
+
const { build } = require("vite");
|
|
8
3
|
const {
|
|
9
4
|
getRootDir,
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
cleanDir,
|
|
6
|
+
watchInputDir,
|
|
12
7
|
writeDemoFile,
|
|
8
|
+
copyAssets,
|
|
9
|
+
watchAssets,
|
|
13
10
|
} = require("@ixon-cdk/core");
|
|
14
11
|
|
|
15
|
-
async function _build(inputFile, outputFile, tag, production, watch) {
|
|
12
|
+
async function _build(inputFile, outputFile, tag, assets, production, watch) {
|
|
16
13
|
const inputDir = path.dirname(path.join(getRootDir(), inputFile));
|
|
17
14
|
const outputDir = path.dirname(path.join(getRootDir(), outputFile));
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
if (fs.existsSync(outputDir)) {
|
|
21
|
-
rimraf.sync(outputDir);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// output folder
|
|
25
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
26
|
-
|
|
27
|
-
// demo file
|
|
16
|
+
cleanDir(outputDir);
|
|
28
17
|
writeDemoFile(tag, outputDir, outputFile);
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
19
|
+
const config = {
|
|
20
|
+
root: getRootDir(),
|
|
21
|
+
mode: production ? "production" : "development",
|
|
22
|
+
build: {
|
|
23
|
+
lib: {
|
|
24
|
+
entry: inputFile,
|
|
25
|
+
formats: ["iife"],
|
|
26
|
+
name: "app",
|
|
27
|
+
fileName: () => `${tag}.min.js`,
|
|
28
|
+
},
|
|
29
|
+
sourcemap: true,
|
|
30
|
+
outDir: outputDir,
|
|
31
|
+
emptyOutDir: false,
|
|
32
|
+
rollupOptions: {
|
|
33
|
+
output: {
|
|
34
|
+
inlineDynamicImports: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
write: true,
|
|
39
|
+
plugins: [],
|
|
46
40
|
};
|
|
47
|
-
if (watch) {
|
|
48
|
-
const watchOptions = {
|
|
49
|
-
...inputOptions,
|
|
50
|
-
output: production
|
|
51
|
-
? [outputOptions, productionOutputOptions]
|
|
52
|
-
: [outputOptions],
|
|
53
|
-
watch: { exclude: ["node_modules/**"] },
|
|
54
|
-
};
|
|
55
|
-
const watcher = await rollup.watch(watchOptions);
|
|
56
|
-
watcher.close();
|
|
57
|
-
} else {
|
|
58
|
-
const bundle = await rollup.rollup(inputOptions);
|
|
59
|
-
await bundle.generate(outputOptions);
|
|
60
|
-
await bundle.write(outputOptions);
|
|
61
|
-
if (production) {
|
|
62
|
-
await bundle.generate(productionOutputOptions);
|
|
63
|
-
await bundle.write(productionOutputOptions);
|
|
64
|
-
}
|
|
65
|
-
await bundle.close();
|
|
66
|
-
}
|
|
67
41
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
42
|
+
// build
|
|
43
|
+
await build(config);
|
|
44
|
+
copyAssets(assets, inputDir, outputDir);
|
|
45
|
+
|
|
46
|
+
// watch source files
|
|
72
47
|
if (watch) {
|
|
73
|
-
|
|
74
|
-
|
|
48
|
+
watchAssets(assets, inputDir, outputDir);
|
|
49
|
+
await watchInputDir(inputDir, (isAsset) => {
|
|
50
|
+
if (isAsset) {
|
|
51
|
+
// do nothing
|
|
52
|
+
} else {
|
|
53
|
+
build(config);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
process.on("SIGINT", () => {
|
|
57
|
+
process.exit();
|
|
75
58
|
});
|
|
76
59
|
}
|
|
77
60
|
}
|
|
@@ -80,8 +63,9 @@ module.exports = function runBuild(
|
|
|
80
63
|
inputFile,
|
|
81
64
|
outputFile,
|
|
82
65
|
tag,
|
|
66
|
+
assets,
|
|
83
67
|
production = true,
|
|
84
68
|
watch = false
|
|
85
69
|
) {
|
|
86
|
-
return _build(inputFile, outputFile, tag, production, watch);
|
|
70
|
+
return _build(inputFile, outputFile, tag, assets, production, watch);
|
|
87
71
|
};
|
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,19 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixon-cdk/static-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": "",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@rollup/plugin-commonjs": "^20.0.0",
|
|
10
|
-
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
11
9
|
"is-potential-custom-element-name": "^1.0.1",
|
|
12
|
-
"
|
|
13
|
-
"rollup": "^2.56.3",
|
|
14
|
-
"rollup-plugin-terser": "^7.0.2"
|
|
10
|
+
"vite": "^2.6.12"
|
|
15
11
|
},
|
|
16
12
|
"peerDependencies": {
|
|
17
|
-
"@ixon-cdk/core": "^1.0.0-alpha.
|
|
13
|
+
"@ixon-cdk/core": "^1.0.0-alpha.6"
|
|
18
14
|
}
|
|
19
15
|
}
|