Is there any way to receive current file path, like in requirejs?
define(['module'], function (module) {
console.log(module.uri)
});
Is there any way to receive current file path, like in requirejs?
define(['module'], function (module) {
console.log(module.uri)
});
To get the filename an the dir name I added this to the web pack config
setting the context to __dirname messed up my web pack config since I have my webpackconfig not placed in root but the paths are setup that way
Yep there is one:
__filename
.But by default webpack doesn't leak path information and you need to set a config flag to get real filename instead of a mock (
"/index.js"
).Than you can use
__filename
get the current filename relative to thecontext
option:The filename is only embedded into modules where
__filename
is used. So you don't have to be affraid that paths are leaked from other modules.