-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathcustom-elements-manifest.config.js
More file actions
75 lines (70 loc) · 2.29 KB
/
custom-elements-manifest.config.js
File metadata and controls
75 lines (70 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { modulePathResolverPlugin } from '@wc-toolkit/module-path-resolver';
import { cemValidatorPlugin } from '@wc-toolkit/cem-validator';
import { getTsProgram, typeParserPlugin } from '@wc-toolkit/type-parser';
import { cemInheritancePlugin } from '@wc-toolkit/cem-inheritance';
export default {
/** Globs to analyze */
globs: ['src/**/*.ts'],
/** Directory to output the manifest to */
outdir: './',
/** Disable package.json updates */
packagejson: false,
/** Globs to exclude */
exclude: [
'_docs/**/*',
'src/**/*.bench.ts',
'src/**/*.definition.ts',
'src/**/*.options.ts',
'src/**/*.spec.ts',
'src/**/*.stories.ts',
'src/**/*.styles.ts',
'src/**/*.template.ts',
'src/**/define.ts',
'src/**/index.ts',
],
/** Enable special handling for fast */
fast: true,
/** Provide custom plugins */
plugins: [
modulePathResolverPlugin({
modulePathTemplate: (modulePath, name, tagName) => `./dist/esm/${getFolderName(name)}/${getFileName(name)}`,
definitionPathTemplate: (modulePath, name, tagName) => `./dist/esm/${getFolderName(name)}/define.js`,
}),
typeParserPlugin(),
cemInheritancePlugin(),
cemValidatorPlugin({
rules: {
packageJson: {
main: 'off',
module: 'off',
types: 'off',
customElements: 'off',
},
manifest: {
schemaVersion: 'off',
},
},
}),
],
/** Overrides default module creation: */
overrideModuleCreation({ ts, globs }) {
const program = getTsProgram(ts, globs, 'tsconfig.json');
return program.getSourceFiles().filter(sf => globs.find(glob => sf.fileName.includes(glob)));
},
};
function getFolderName(baseName) {
// Convert "BaseAccordionItem" to "accordion-item"
return baseName
.replace(/^Base/, '') // Remove the "Base" prefix
.replace(/([a-z])([A-Z])/g, '$1-$2') // Convert camelCase to kebab-case
.toLowerCase();
}
function getFileName(baseName) {
// Convert "BaseAccordionItem" to "accordion-item"
const kebabCaseName = baseName
.replace(/^Base/, '') // Remove the "Base" prefix
.replace(/([a-z])([A-Z])/g, '$1-$2') // Convert camelCase to kebab-case
.toLowerCase();
// Construct the file path
return `${kebabCaseName}${baseName.includes('Base') ? '.base' : ''}.js`;
}