question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What's the right way to add asset from a plugin

See original GitHub issue

My webpack plugin created new file e.g. ccc.svg. How can i add it to assets array from apply plugin section so it will appear in output path as:

MyPlugin.prototype.apply = function(compiler) {

   var assetName = 'ccc.svg',
       assetContent = '<svg>123</svg>';

   compiler.plugin('add-asset', function(assetsArray) {
      assetsArray[assetName] = assetContent;
   }
}

So if I have structure like:

inputPath — assets ------- aaa.svg ------- bbb.svg

and after webpack compilation:

outputPath — assets ------- asd2131wdsf32fwer2.aaa.svg ------- gfdg8dfgdfg7dfg8dfg.bbb.svg ------- kj234hf24fwer9ger8f2.ccc.svg

It should be simple operation, but i couldn’t find a solution.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dev-bjoerncommented, May 19, 2019

Did anyone manage to solve this? Having the same problem right now…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How Your Plugin Assets Work | Plugin Developer Handbook
The assets folder in your plugin is where you can store images (like plugin headers, icons, and screenshots) used on your plugin's display...
Read more >
How Plugin Developers Should Manage Image Assets
Plugin developers should use assets like a banner image, screenshots and icon, to show off their plugin in search results. Here's how to...
Read more >
Guide to Using the Unity Asset Store to Find Plugins and Models
Unity 2018 Video Course 25% Off ▻▻ http://bit.ly/Unity2018Course◢◤◣◥◢◤◣◥◢◤◣◥◢◤◣◥HUGE Course on Unity ...
Read more >
How to add image asset when creating a plugin
Plugins can only contain these 3 files: manifest.json; code.js; ui.html. Images, fonts, scripts and other resources can only be connected by URL ...
Read more >
An Introduction to Asset Handling in WordPress
WordPress has provided a few basic functions to help the developer correctly load custom assets of their theme or plugin.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found