storybook-addon-sdc 0.18.1 → 0.18.2

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.
Files changed (2) hide show
  1. package/dist/preset.js +19 -8
  2. package/package.json +1 -1
package/dist/preset.js CHANGED
@@ -425,14 +425,25 @@ var readSDC = (filePath, defs, validate) => {
425
425
  }
426
426
  return sdcSchema;
427
427
  };
428
- var generateImports = (directory, namespaces) => readdirSync2(directory).filter(
429
- (file) => [".css", ".js", ".mjs", ".twig", ".yml"].includes(extname(file))
430
- ).map((file) => {
431
- const filePath = `./${file}`;
432
- const namespace = namespaces.pathToNamespace(directory);
433
- logger.info(`IMPORT ASSET ${directory}/${file}`);
434
- return extname(file) === ".twig" ? `import COMPONENT from '${namespace}/${file}';` : `import '${filePath}';`;
435
- }).join("\n");
428
+ var generateImports = (directory, namespaces) => {
429
+ const componentName = basename2(directory);
430
+ return readdirSync2(directory).filter(
431
+ (file) => [".css", ".js", ".mjs", ".twig", ".yml"].includes(extname(file))
432
+ ).map((file) => {
433
+ const filePath = `./${file}`;
434
+ const namespace = namespaces.pathToNamespace(directory);
435
+ logger.info(`IMPORT ASSET ${directory}/${file}`);
436
+ if (extname(file) === ".twig") {
437
+ const fileName = basename2(file, ".twig");
438
+ if (fileName === componentName) {
439
+ return `import COMPONENT from '${namespace}/${file}';`;
440
+ }
441
+ logger.info(`Skipping variant template: ${file}`);
442
+ return "";
443
+ }
444
+ return `import '${filePath}';`;
445
+ }).filter(Boolean).join("\n");
446
+ };
436
447
  var dynamicImports = (stories, namespaces) => {
437
448
  const imports = /* @__PURE__ */ new Set();
438
449
  const importComponent = (item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-sdc",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "Drupal Single Directory Components as stories",
5
5
  "keywords": [
6
6
  "SDC",