electron-webpack
electron-webpack copied to clipboard
__static documentation
- 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'sresourcesPath
(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;
.
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
I think we still have lots to improve in the docs. Meanwhile: https://github.com/loopmode/electron-webpack-static-examples