Skip to content

'Module not found: Error: Can't resolve` when use a mixin and require on same file #123

@felipefialho

Description

@felipefialho

Hi, I tried help here (pugjs/pug#3164) before.


Pug Version: 2.0.4

Node Version: v11.10.0

Input JavaScript Values

new HtmlWebpackPlugin({  
  hash: true, 
  template: './src/index.pug'
}),

Input Pug

- var css = require('./person-css.json');
- var variables = require('../../variables.json');

mixin person(image, subtitle, link)
  h1(class=css.title) 
- var css = require('./section-css.json');
include ../person/person

section(class=css.host)
  +person('Person')

Additional Comments

If I remove mixin, require works fine and compile as expected. But when I used mixin I get the follows errors:

ERROR in ./src/index.pug (./node_modules/html-webpack-plugin/lib/loader.js!./src/index.pug)
    Module not found: Error: Can't resolve '../../variables.json' in 'my-project/src'
     @ ./src/index.pug (./node_modules/html-webpack-plugin/lib/loader.js!./src/index.pug) 7:16-47
    
ERROR in ./src/index.pug (./node_modules/html-webpack-plugin/lib/loader.js!./src/index.pug)
    Module not found: Error: Can't resolve './person-css.json' in 'my-project/src'
     @ ./src/index.pug (./node_modules/html-webpack-plugin/lib/loader.js!./src/index.pug) 6:10-38

Maybe this is an issue for pug-loader.

Thanks!

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