Skip to content

Commit 08c2625

Browse files
authored
Merge pull request #59 from sitegeist/task/cleanupJsAndCssArtefacts
Task/cleanup js and css artefacts
2 parents c414e6c + e468ba0 commit 08c2625

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

DistributionPackages/Vendor.Site/Build/JavaScript/fusion-loader.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@ module.exports = function (fusionSource) {
2121
exportStatements.push('export {styles};');
2222
}
2323

24+
if (!fs.existsSync(`${basePath}.css`) && fs.existsSync(`${basePath}.css.fusion`)) {
25+
fs.unlinkSync(`${basePath}.css.fusion`);
26+
}
27+
2428
if (fs.existsSync(`${basePath}.js`)) {
2529
throw new Error(`Do not use JS files for components. Please create a "${path.basename(basePath)}.ts" instead.`);
2630
}
2731

32+
if (!fs.existsSync(`${basePath}.ts`) && !fs.existsSync(`${basePath}.js`) && fs.existsSync(`${basePath}.js.fusion`)) {
33+
fs.unlinkSync(`${basePath}.js.fusion`);
34+
}
35+
2836
if (fs.existsSync(`${basePath}.ts`)) {
2937
importStatements.push(`import script from '${basePath}.ts';`);
3038
exportStatements.push('export {script};');

DistributionPackages/Vendor.Site/Resources/Private/Fusion/Root.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export default function main(components: ComponentsDefinition) {
1818
if (componentName in components) {
1919
const {script, prototypeName, styles} = components[componentName];
2020

21-
script(el, {prototypeName, styles});
21+
if (script) {
22+
script(el, {prototypeName, styles});
23+
return;
24+
}
25+
2226
return;
2327
}
2428

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,14 @@ install::
7777
flush::
7878
@ddev composer flush
7979

80+
remove-artefacts:
81+
@ddev exec find ./DistributionPackages/ -type f -name '*.js.fusion' -delete
82+
@ddev exec find ./DistributionPackages/ -type f -name '*.css.fusion' -delete
83+
8084
cleanup::
8185
@ddev composer cleanup:php
8286
@ddev yarn cleanup:node
87+
@$(MAKE) -s remove-artefacts
8388

8489
###############################################################################
8590
# LINTING & QA #

0 commit comments

Comments
 (0)