Commit 438033d2 authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3299786: Configure Twig Namespaces to work for nested components and Drupal template system

parent 4fba242b
Loading
Loading
Loading
Loading

.storybook/main.js

0 → 100755
+1 −0
Original line number Diff line number Diff line
+1 −1

File changed and moved.

Contains only whitespace changes.

+3 −3
Original line number Diff line number Diff line
import { configure } from '@storybook/html';
import Twig from 'twig';
import twig from 'twig';
import twigDrupal from 'twig-drupal-filters';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap/dist/js/bootstrap';
// Add the filters to Twig instance.
twigDrupal(Twig);

configure(require.context('../src/components', true, /\.stories\.js$/), module);

twigDrupal(twig);
+34 −6
Original line number Diff line number Diff line
@@ -2,20 +2,48 @@ const path = require('path');

module.exports = ({ config }) => {

  // Twig:
  // Twig
  config.module.rules.push({
    test: /\.twig$/,
    use: [{
    test: /\.(html.twig|twig)$/,
    use: [
      {
        loader: 'twig-loader',
    }, ],
        options: {
          twigOptions: {
            namespaces: {
              vartheme_bs5: path.resolve(__dirname, '../', 'src/components'),
              atoms: path.resolve(__dirname, '../', 'src/components/atoms'),
              molecules: path.resolve(__dirname, '../', 'src/components/molecules'),
              organisms: path.resolve(__dirname, '../', 'src/components/organisms'),
              templates: path.resolve(__dirname, '../', 'src/components/templates'),
              pages: path.resolve(__dirname, '../', 'src/components/pages'),
            },
          },
        },
      },
    ],
  });

  // Sass:
  config.module.rules.push({
    test: /\.scss$/,
    test: /\.s[ac]ss$/i,
    use: ['style-loader', 'css-loader', 'sass-loader'],
    include: path.resolve(__dirname, '../'),
  });

  // Row text loader.
  config.module.rules.push({
    test: /\.txt$/i,
    use: [
      {
        loader: 'raw-loader',
        options: {
          esModule: false,
        },
      },
    ],
  });

  return config;
};
+5 −2
Loading