@blueprintui/cli 0.0.5 → 0.0.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/.nvmrc +1 -1
- package/README.md +20 -0
- package/custom-elements-manifest.config.mjs +16 -4
- package/package.json +1 -1
- package/rollup.config.mjs +20 -10
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
18.3.0
|
package/README.md
CHANGED
|
@@ -15,3 +15,23 @@ Web Component libraries. This project is still an experimental work in progress.
|
|
|
15
15
|
| -------------- | ------------------------------------------ |
|
|
16
16
|
| --config | Path for `blueprint.config.js` file |
|
|
17
17
|
| --watch | Runs build in watch mode for development |
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Configuration
|
|
21
|
+
|
|
22
|
+
The `blueprint.config.js` can be used to customize certain aspects of the build.
|
|
23
|
+
Below are the default values unless otherwise specified.
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
export default {
|
|
27
|
+
library: {
|
|
28
|
+
externals: [],
|
|
29
|
+
assets: ['./README.md', './LICENSE.md', './package.json'],
|
|
30
|
+
baseDir: './src',
|
|
31
|
+
outDir: './dist/lib',
|
|
32
|
+
entryPoints: ['./src/**/index.ts'],
|
|
33
|
+
tsconfig: './tsconfig.lib.json',
|
|
34
|
+
sourcemap: false,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
import { resolve } from 'path';
|
|
3
3
|
|
|
4
4
|
const cwd = process.cwd();
|
|
5
|
+
const baseSrc = resolve(cwd, 'src');
|
|
6
|
+
|
|
7
|
+
let userConfig = { };
|
|
8
|
+
if (process.env.BLUEPRINTUI_CONFIG) {
|
|
9
|
+
userConfig = await import(process.env.BLUEPRINTUI_CONFIG);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const config = {
|
|
13
|
+
baseDir: './src',
|
|
14
|
+
outDir: './dist/lib',
|
|
15
|
+
...userConfig?.default?.library
|
|
16
|
+
};
|
|
5
17
|
|
|
6
18
|
export default {
|
|
7
|
-
globs: [resolve(cwd,
|
|
8
|
-
outdir:
|
|
19
|
+
globs: [resolve(cwd, config.baseDir)],
|
|
20
|
+
outdir: config.outDir,
|
|
9
21
|
litelement: true,
|
|
10
22
|
plugins: [tsExtensionPlugin(), baseDir(), orderElements()],
|
|
11
23
|
};
|
|
@@ -19,12 +31,12 @@ export function orderElements() {
|
|
|
19
31
|
};
|
|
20
32
|
}
|
|
21
33
|
|
|
22
|
-
export function baseDir(
|
|
34
|
+
export function baseDir() {
|
|
23
35
|
return {
|
|
24
36
|
name: 'base-dir',
|
|
25
37
|
packageLinkPhase({ customElementsManifest }) {
|
|
26
38
|
customElementsManifest.modules = JSON.parse(
|
|
27
|
-
JSON.stringify(customElementsManifest.modules).replaceAll(`"/${
|
|
39
|
+
JSON.stringify(customElementsManifest.modules).replaceAll(`"/${baseSrc}`, '"').replaceAll(`"${baseSrc}`, '"')
|
|
28
40
|
);
|
|
29
41
|
},
|
|
30
42
|
};
|
package/package.json
CHANGED
package/rollup.config.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import copy from 'rollup-plugin-copy';
|
|
|
7
7
|
import del from 'rollup-plugin-delete';
|
|
8
8
|
import minifyHTML from 'rollup-plugin-minify-html-literals';
|
|
9
9
|
import execute from 'rollup-plugin-shell';
|
|
10
|
-
import { fs, glob, path } from 'zx';
|
|
10
|
+
import { $, fs, glob, path } from 'zx';
|
|
11
11
|
import { extname } from 'path';
|
|
12
12
|
import { terser } from 'rollup-plugin-terser';
|
|
13
13
|
import { importAssertions } from 'acorn-import-assertions';
|
|
@@ -26,12 +26,11 @@ if (process.env.BLUEPRINTUI_CONFIG) {
|
|
|
26
26
|
|
|
27
27
|
const config = {
|
|
28
28
|
externals: [],
|
|
29
|
-
assets: ['./README.md', './LICENSE', './package.json'],
|
|
29
|
+
assets: ['./README.md', './LICENSE.md', './package.json'],
|
|
30
30
|
baseDir: './src',
|
|
31
31
|
outDir: './dist/lib',
|
|
32
|
-
entryPoints: ['./src/**/index.ts'
|
|
32
|
+
entryPoints: ['./src/**/index.ts'],
|
|
33
33
|
tsconfig: './tsconfig.lib.json',
|
|
34
|
-
customElementsManifestConfig: './custom-elements-manifest.config.mjs',
|
|
35
34
|
sourcemap: false,
|
|
36
35
|
...userConfig.default?.library
|
|
37
36
|
};
|
|
@@ -45,7 +44,7 @@ const project = {
|
|
|
45
44
|
outDir: path.resolve(cwd, config.outDir),
|
|
46
45
|
entryPoints: config.entryPoints.map(e => path.resolve(cwd, e)),
|
|
47
46
|
tsconfig: path.resolve(cwd, config.tsconfig),
|
|
48
|
-
customElementsManifestConfig: path.resolve(
|
|
47
|
+
customElementsManifestConfig: config.customElementsManifestConfig ? path.resolve(cwd, config.customElementsManifestConfig) : path.resolve(__dirname, './custom-elements-manifest.config.mjs'),
|
|
49
48
|
prod: process.env.BLUEPRINTUI_BUILD === 'production',
|
|
50
49
|
sourcemap: config.sourcemap
|
|
51
50
|
}
|
|
@@ -79,7 +78,8 @@ export default [
|
|
|
79
78
|
project.prod ? inlinePackageVersion() : [],
|
|
80
79
|
project.prod ? postClean(): [],
|
|
81
80
|
project.prod ? packageCheck() : [],
|
|
82
|
-
|
|
81
|
+
project.prod ? customElementsAnalyzer() : [],
|
|
82
|
+
project.prod ? cleanPackageJson() : []
|
|
83
83
|
],
|
|
84
84
|
},
|
|
85
85
|
];
|
|
@@ -132,15 +132,25 @@ function customElementsAnalyzer() {
|
|
|
132
132
|
if (copied) {
|
|
133
133
|
return;
|
|
134
134
|
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
await fs.writeFile(`${project.outDir}/package.json`, JSON.stringify(packageFile, null, 2));
|
|
135
|
+
const cemPath = path.resolve('node_modules', '@custom-elements-manifest/analyzer/index.js');
|
|
136
|
+
await $`${cemPath} analyze --config ${project.customElementsManifestConfig}`;
|
|
137
|
+
copied = true;
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
140
|
};
|
|
142
141
|
}
|
|
143
142
|
|
|
143
|
+
function cleanPackageJson() {
|
|
144
|
+
return {
|
|
145
|
+
name: 'clean-package-json',
|
|
146
|
+
writeBundle: async () => {
|
|
147
|
+
const json = await fs.readJson(project.packageFile);
|
|
148
|
+
const packageFile = { ...json, scripts: undefined, devDependencies: undefined };
|
|
149
|
+
await fs.writeFile(`${project.outDir}/package.json`, JSON.stringify(packageFile, null, 2));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
144
154
|
function cssOptimize() {
|
|
145
155
|
return {
|
|
146
156
|
load(id) { return id.slice(-4) === '.css' ? this.addWatchFile(path.resolve(id)) : null },
|