Until then, you can use something like this instead of require. Require.resolve with paths and non-existent directory returns incorrect local file when using. You can see it here and watch if it gets fixed: There is a bug with require.resolve when passing paths as an option. If I explicitly pass require as my local then the path would be the folder of that file where I passed local require. That is from where I render my pug templates so that is from where it is available. If I do ('./') inside any of my pug files, it will show me that the path in which resolve happens is inside my routes. I also didn't pass in process.env but it is also available. I didn't have to pass require statement to my pug locals. We’ll make use of axios as our HTTP client for the requests to the Random User API. The first is going to initialize our folder with a package.json, and the second will install the npm dependencies needed. babelrc.js and populate paths by yourself. In a folder of your choice, run the following commands: npm init -y npm install express pug axios. ![]() You can either pass manually all those aliases and roots to the paths option inside require.resolve or you can write your own logic that reads configuration from. ![]() The root directory of all absolute inclusion. Used in exceptions, and required for relative include \s and extend \s. Const path = require ( 'path' ) const walk = require ( 'pug-walk' ) const runtime = require ( 'pug-runtime' ) const _ = require ( 'lodash' ) const pugPluginRequire = ( ) => ( `) this will be ignored and not manipulated as it doesn't match regexp.Īlso, if you are using some kind of module resolver, for instance babel-plugin-module-resolver that will not work out of the box. All API methods accept the following set of options: filename: string.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |