Skip to content

Instantly share code, notes, and snippets.

@bbudd
bbudd / assets.md
Created June 13, 2019 12:30
Loading static assets using electron-forge v6 and the webpack plugin

I spent a few hours chasing down just how to get my static assets (css, fonts, images) to load in an Electron app built using electron-forge v6 (https://www.electronforge.io/) and its webpack plugin (https://www.electronforge.io/config/plugins/webpack) while in development mode. There really isn't any documentation available online, either in the electron-forge documentation or in places like blogs or gists or stackoverflow. So I thought I'd put it down here.

Step 1

Load CopyWebpackPlugin npm i -D copy-webpack-plugin


Step 2

Use the plugin to move your directories into place.

In an overall sense, it's pretty ovious that the person/people who wrote this wrote it under the assumption that there was sort of one way of writing it, so a lot of this seems shoehorned into a "dictated style." I'm a bit wary of that to begin with - you shouldn't be figuring out how to make your tools do the job, you should be figuring out the best tools for the job. (It's also obvious that there's no real technical lead in their group who oversees their coding and applies some sort of standards to what they're doing.)

For example:

  • Their code comments seem to be literally only commented-out code that didn't work for whatever reason. Why is this? This is a HUGE red flag. If I'm building code that I know will be passed off to someone else to maintain, I comment the shit out of that code. This way it's readily apparent what the code does. I don't just leave it up to "they'll figure it out." That doesn't speak well to my own understanding of my responsibility as a vendor.

  • Why are there any backbone mo