Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JuiceLink with SCSS in a Twig template doesn't seem to work #4

Open
en-hdettmann opened this issue Jun 11, 2024 · 0 comments
Open

Comments

@en-hdettmann
Copy link

en-hdettmann commented Jun 11, 2024

Hey,

I'm trying to compile a Twig template with Vituum that uses some SCSS files for styling. So far I'm able to compile it successfully but I need to also inline the generated CSS in the final HTML with this plugin but unfortunately I didn't got it working yet.

The setup for the juice plugin looks like this:

juice({
    paths: ['./static-pages/pages'],
    juiceLink: async (href) => sass.compile(href).css
}),

In the Twig template I changed the link tag to:
<link rel="stylesheet" data-href="/assets/scss/styles.scss" data-juice-link>

When I try to build I get this error:

file:///path/to/node_modules/@vituum/vite-plugin-juice/index.js:62
                        const href = link.attrs.filter(({ name }) => name === 'data-href')[0].value
                                                                                             ^

TypeError: Cannot read properties of undefined (reading 'value')

It looks to me that the tag is gone after Twig has done its job. Any ideas how to avoid this?

Thanks for any feedback and help here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant