mikemartin / laravel-mix-pug-recursive

Laravel Mix Plugin for compiling Pug/Jade templates.
MIT License
2 stars 5 forks source link

TypeError: Cannot read property 'glob' of undefined #3

Closed linbaicheng closed 3 years ago

linbaicheng commented 3 years ago

The background:

// webpack.mix.js

let mix = require('laravel-mix');
mix.pug = require('laravel-mix-pug-recursive');

mix.js('src/app.js', 'dist')
   .sass('src/app.scss', 'dist')
   .pug('src/**/*.pug', 'dist')
   .setPublicPath('dist');

Run npx mix

$ npx mix

Report errors below:

[webpack-cli] TypeError: Cannot read property 'glob' of undefined
    at Object.pug (/private/tmp/larvel/node_modules/laravel-mix-pug-recursive/src/index.js:17:30)
    at Object.<anonymous> (/private/tmp/larvel/webpack.mix.js:6:5)
    at Module._compile (/private/tmp/larvel/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (/private/tmp/larvel/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at module.exports (/private/tmp/larvel/node_modules/laravel-mix/setup/webpack.config.js:8:5)
    at /private/tmp/larvel/node_modules/webpack-cli/lib/webpack-cli.js:1222:43
hectorsevillasandoval commented 3 years ago

Hey @linbaicheng, Could you try adding an empty object as a third parameter in here: .pug('src/**/*.pug', 'dist',{})

mikemartin commented 3 years ago

@linbaicheng Can confirm that @barcadictni's workaround will work. But this seems to be a regression from this bugfix from @RikutoYamaguchi https://github.com/mikemartin/laravel-mix-pug-recursive/commit/d474cdce836204b47e6c9e7c7fc9bffceb121080

RikutoYamaguchi commented 3 years ago

@mikemartin I'm sorry. Fixed a bug in https://github.com/mikemartin/laravel-mix-pug-recursive/pull/5

mikemartin commented 3 years ago

Thanks @RikutoYamaguchi for the fix. 👍

linbaicheng commented 3 years ago

Hey @linbaicheng, Could you try adding an empty object as a third parameter in here: .pug('src/**/*.pug', 'dist',{})

@mikemartin @barcadictni Thank you so much! 🙏

# webpack.mix.js
let mix = require('laravel-mix');
mix.pug = require('laravel-mix-pug-recursive');

mix.js('src/app.js', 'dist')
   .sass('src/app.scss', 'dist')
-   .pug('src/**/*.pug', 'dist')
+  .pug('src/**/*.pug', 'dist',{})
   .setPublicPath('dist');

👍 It's looking good.

image

hectorsevillasandoval commented 3 years ago

Hey @linbaicheng, Could you try adding an empty object as a third parameter in here: .pug('src/**/*.pug', 'dist',{})

@mikemartin @barcadictni Thank you so much! 🙏

# webpack.mix.js
let mix = require('laravel-mix');
mix.pug = require('laravel-mix-pug-recursive');

mix.js('src/app.js', 'dist')
   .sass('src/app.scss', 'dist')
-   .pug('src/**/*.pug', 'dist')
+  .pug('src/**/*.pug', 'dist',{})
   .setPublicPath('dist');

👍 It's looking good.

image

Try adding this to the options: .pug('src/**/*.pug', 'dist',{ excludePath: 'src' })