javascript - Dynamic file path in require with webpack? -


this works fine when manually request file using require, moment use exact same request, change string it's split variables fails.

this works great:

module.exports = (function() {     var $svg = require('svg-inline!../../assets/svgs/global/connected.svg');     console.log($svg); }()); 

however if this:

module.exports = (function() {     var $path = '../../assets/svgs/global/';     var $svg = require('svg-inline!'+$path+'connected.svg');     console.log($svg); }()); 

it fails , says inside console:

uncaught error: cannot find module "."

i guess question why can't concatenate strings have here?

i think have webpack context. when try require contains expression, webpack create context. expression treated regular expression , doesn't work may expect.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -