Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forge.config.js in packagerConfig.ignore Not processing all paths #3293

Closed
3 tasks done
ht-sauce opened this issue Aug 8, 2023 · 2 comments
Closed
3 tasks done

forge.config.js in packagerConfig.ignore Not processing all paths #3293

ht-sauce opened this issue Aug 8, 2023 · 2 comments
Labels
bug package Issues related to the `package` command

Comments

@ht-sauce
Copy link

ht-sauce commented Aug 8, 2023

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

6.2.1

Electron version

25.3.1

Operating system

Windows 10

Last known working Electron Forge version

6.2.1

Expected behavior

packagerConfig.ignore All paths should be processed

Actual behavior

I want to optimize the volume of packaged files and preserve specific files through the ignore function, but I found that the ignore function does not handle all paths
Please take a look at the ignore section in my code. This logic is very simple, but/node_ Modules/electric squirrel startup, some of which were not matched

Steps to reproduce

module.exports = {
  packagerConfig: {
    icon: 'public/icon',
    // asar: true,
    version: '1.0.0', // 应用程序版本号
    // 不需要打包的文件和文件夹的路径列表,true表示忽略,false表示包含
    ignore(path) {
      if (!path) return false
      if (path.includes('/node_modules/electron-squirrel-startup')) return false
      if (path.includes('/.vite')) return false
      if (path.includes('/package.json')) return false

      return true
    },
  },
  rebuildConfig: {},
  makers: [
    {
      name: '@electron-forge/maker-squirrel',
      config: {
        setupIcon: 'public/icon.ico',
      },
    },
    {
      name: '@electron-forge/maker-zip',
      platforms: ['darwin'],
    },
    {
      name: '@electron-forge/maker-deb',
      config: {
        options: {
          icon: 'public/icon.png',
        },
      },
    },
    {
      name: '@electron-forge/maker-rpm',
      config: {},
    },
  ],
  plugins: [
    {
      name: '@electron-forge/plugin-vite',
      config: {
        build: [
          {
            entry: 'src/main.js',
            config: 'vite.main.config.mjs',
          },
          {
            entry: 'src/preload.js',
            config: 'vite.preload.config.mjs',
          },
        ],
        renderer: [
          {
            name: 'main_window',
            config: 'vite.renderer.config.mjs',
          },
        ],
      },
    },
  ],
}

Additional information

No response

@erickzhao erickzhao added bug package Issues related to the `package` command labels Aug 8, 2023
@JoCat
Copy link

JoCat commented Nov 4, 2023

I faced a similar situation and solved it as follows:

ignore(path) {
  if (!path) return false;
  if (path.startsWith("/package.json")) return false;
  // add only the /.vite folder from the project root, ignoring the one in node_modules.
  if (path.startsWith("/.vite")) return false;
  // allow the node_modules folder, if we do not do this, we will not have access to the electron-squirrel-startup folder.
  if (path === "/node_modules") return false;
  if (path.startsWith("/node_modules/electron-squirrel-startup")) return false;

  return true;
}

@caoxiemeihao
Copy link
Member

Fixed in #3336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug package Issues related to the `package` command
Projects
None yet
Development

No branches or pull requests

4 participants