Skip to content

Unable to include twig files outside project path #48

@ilkkave

Description

@ilkkave

Problem/motivation

I would like to include twig files outside the project path, but currently it’s not possible, because twig resolves to wrong path with those files.

An example:
Root for project where I use twig-loader is /some/path/my_project.
I can import twig file from /some/path/my_project/templates/template.twig.
I can’t import twig file from /some/path/templates/template.twig and will get an error like:

ERROR in ../templates/template.twig
Module not found: Error: Can't resolve 'twig' in ‘/some/path/my_project’
 @ ../templates/template.twig 3:11-26
 …

Proposed resolution

Use stringifyRequest (https://github.com/webpack/loader-utils#stringifyrequest) from loader-utils to get path to twig in https://github.com/zimmo-be/twig-loader/blob/master/lib/loader.js#L33.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions