Include assets from webpack bundled npm package Include assets from webpack bundled npm package javascript javascript

Include assets from webpack bundled npm package


Figured out a way around this.

In my application's webpack config I added a plugin (recommended by @Interrobang) which copies the static assets from the node_module/my-package into the app server's public path:

var TransferWebpackPlugin = require('transfer-webpack-plugin');...plugins: [  new TransferWebpackPlugin([    { from: 'node_modules/my-package/assets', to: path.join(__dirname, 'my/public') }  ])]...

These will then be made accessible by calling the asset name: localhost:XXXX/my-image.jpg. The server here is basically looking at /my/public/my-image.jpg if you've set it up correctly.

I'm using Express, so I just had to define app.use(express.static('my/public')) in my app server.