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.

main static file copy

See original GitHub issue

It seems the files option is electron-builder.json define the file from build folder to dist\xxx-unpacked\resources\app because I found out the main static files are not copied from src\main\static to build\main\static on win11, so I added below code to function buildMain() in build.js

    FileSystem.cpSync(Path.join(__dirname, '..', 'src', 'main', 'static'), Path.join(__dirname, '..', 'build', 'main', 'static'), {recursive:true});

Did you encounter this issue?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Deluzecommented, May 25, 2022

You made me think of a potentially better solution @immafrady 👍

We could check if the change happened to one of the static files. Copy only and only the static file that got changed & restart Electron after. When a change has been made outside of the static files, we don’t have to copy anything explicitly.

Update: Already implemented now in 4f3d845aef01df0f54f581981b2aa7fc46c0f0fc

1reaction
Deluzecommented, May 24, 2022

This is unintended.

The following line of code is being fired when you spin up the dev server:

FileSystem.cpSync(
  Path.join(__dirname, '..', 'src', 'main', 'static'), 
  Path.join(__dirname, '..', 'build', 'main', 'static'), 
  { recursive: true }
);

The electron-builder config is ignored when you work in a dev environment, electron-builder config is only used when you actually build the application for production / distributing. I didn’t encounter an issue with static files, I’m also on W11/MacOS. So your PR (#18) is incorrect, following the README on how static files should work.

A little side note that is missing from the README is that static files are only copied over ONCE after running npm run dev, if you added new files to the static directory you will need to restart your dev server. This is to prevent copying over static (potentionally big) files after every change.

I’ll close this issue & PR with the assumption of that you didn’t restart your dev server. If that’s not the case and there’s actually another issue going on please re-open this 😄 I’ll also extend the readme with more details about this behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nickjj/esbuild-copy-static-files - GitHub
An esbuild plugin to efficiently copy static files from a source directory to a destination directory. ✔️ Only copy files that changed (it...
Read more >
How to copy static files to build directory with Webpack?
I'm trying to move from Gulp to Webpack . In Gulp I have task which copies all files and folders from /static/ folder...
Read more >
parcel-plugin-static-files-copy - npm
ParcelJS plugin to copy static files from static dir to bundle directory.. Latest version: 2.6.0, last published: 2 years ago.
Read more >
File.Copy Method (System.IO) - Microsoft Learn
Copy (String, String, Boolean) ... Copies an existing file to a new file. Overwriting a file of the same name is allowed. public:...
Read more >
"copy-static-assets" task - Rush Stack
This task supplements the TypeScript transpiler by copying asset files into the output folder, so that they can be imported by .js files....
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