Skip to content

Commit 89e1a6c

Browse files
committed
💄 rename files to camel case and fix loader generation
1 parent 74cda5d commit 89e1a6c

15 files changed

+22
-15
lines changed

personalization-webcomponents/index-checklist-detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<!-- built files will be auto injected -->
3232
<script
33-
src="src/checklist-detail-webcomponent.ts"
33+
src="src/ChecklistDetailWebcomponent.ts"
3434
type="module"
3535
></script>
3636
</head>

personalization-webcomponents/index-checklist-overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<!-- built files will be auto injected -->
3232
<script
33-
src="src/checklist-overview-webcomponent.ts"
33+
src="src/ChecklistOverviewWebcomponent.ts"
3434
type="module"
3535
></script>
3636
</head>

personalization-webcomponents/index-checklist-preview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<!-- built files will be auto injected -->
3232
<script
33-
src="src/checklist-preview-webcomponent.ts"
33+
src="src/ChecklistPreviewWebcomponent.ts"
3434
type="module"
3535
></script>
3636
</head>

personalization-webcomponents/index-my-checklists.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<!-- built files will be auto injected -->
3232
<script
33-
src="src/my-checklists-webcomponent.ts"
33+
src="src/MyChecklistsWebcomponent.ts"
3434
type="module"
3535
></script>
3636
</head>

personalization-webcomponents/processes/lib/fileGenerator.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ export function generateLoaderJs(filename, subdirectory, suffix) {
1515
"{{path}}",
1616
`../${subdirectory}/${filename}`
1717
);
18+
19+
const dirName = changeCamelToSnakeCase(suffix);
1820
// write script to the dist folder as loader.js.template
19-
fs.mkdirSync(`./dist/${suffix}`, { recursive: true });
21+
fs.mkdirSync(`./dist/${dirName}`, { recursive: true });
2022
fs.writeFileSync(
21-
path.resolve(`./dist/${suffix}/loader.js`),
23+
path.resolve(`./dist/${dirName}/loader.js`),
2224
loaderJsReplaced,
2325
{
2426
encoding: "utf-8",
2527
}
2628
);
2729
}
30+
31+
function changeCamelToSnakeCase(camelCased) {
32+
const snakeCased = camelCased.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
33+
return snakeCased.startsWith('_') ? snakeCased.substring(1) : snakeCased;
34+
}

personalization-webcomponents/processes/post-build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import manifest from '../dist/src/.vite/manifest.json' with {type: 'json'};
2727

2828
// Required filename content to be treated as webcomponent
2929
const REQUIRED_PREFIX = 'src/';
30-
const REQUIRED_SUFFIX = '-webcomponent.ts';
30+
const REQUIRED_SUFFIX = 'Webcomponent.ts';
3131

3232
for (const key in manifest) {
3333
if (key.startsWith(REQUIRED_PREFIX) && key.endsWith(REQUIRED_SUFFIX)) {
File renamed without changes.

personalization-webcomponents/src/checklist-detail-webcomponent.ts renamed to personalization-webcomponents/src/ChecklistDetailWebcomponent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineCustomElement } from "vue";
22

3-
import ChecklistDetailVueComponent from "@/checklist-detail.ce.vue";
3+
import ChecklistDetailVueComponent from "@/ChecklistDetail.ce.vue";
44

55
// convert into custom element constructor
66
const ChecklistDetailWebcomponent = defineCustomElement(
File renamed without changes.

personalization-webcomponents/src/checklist-overview-webcomponent.ts renamed to personalization-webcomponents/src/ChecklistOverviewWebcomponent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineCustomElement } from "vue";
22

3-
import ChecklistOverviewVueComponent from "@/checklist-overview.ce.vue";
3+
import ChecklistOverviewVueComponent from "@/ChecklistOverview.ce.vue";
44

55
// convert into custom element constructor
66
const ChecklistOverviewWebcomponent = defineCustomElement(

0 commit comments

Comments
 (0)