electron-webpack icon indicating copy to clipboard operation
electron-webpack copied to clipboard

__static documentation

Open jacobweber opened this issue 4 years ago • 2 comments

  • electron-webpack: 2.7.4
  • electron-builder: 22.4.0
  • electron-updater: N/A
  • Target: OS X

I think there should be some additional documentation around __static. In particular, it should explain that:

  • when you build in production mode, it points to a static directory inside the app's resourcesPath (as far as I can tell).
  • if you want this to actually contain something, you'll need to do it yourself, e.g. using electron-builder's extraResources setting.
  • this means that if you build in production mode, and then run the app with npx electron ., it will point to the runtime Electron app, e.g. node_modules/electron/dist/Electron.app/Contents/Resources/static, which will definitely never contain anything. So it really can't be used in this mode; you have to use electron-builder.
  • to use it with TypeScript you'll need to add declare const __static: string;.

jacobweber avatar Mar 15 '20 20:03 jacobweber

The documentation makes clear PT#1 https://webpack.electron.build/using-static-assets

In any environment, a single build process isn't always sufficient for readying your product for production. You would consider moving additional artifacts to the __static directory by other methods (such as extraResources or simple bash cp). Personally, I have a bash file that runs a whole bunch of nonsense including, but not limited to, electron-builder

Your TypeScript point is very fair!! Please could you consider adding to the documentation yourself by forking this: https://github.com/electron-userland/electron-webpack/blob/master/docs/en/using-static-assets.md

MatthewRorke avatar May 12 '20 13:05 MatthewRorke

I think we still have lots to improve in the docs. Meanwhile: https://github.com/loopmode/electron-webpack-static-examples

loopmode avatar Aug 17 '20 08:08 loopmode