Skip to content

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

Closed

Description

@ht-sauce

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

Activity

  1. added
    package
    on Aug 8, 2023
  2. JoCat commented on Nov 4, 2023

    @JoCat

    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;
    }
  3. caoxiemeihao commented on Jan 17, 2024

    @caoxiemeihao
    Member

    Fixed in #3336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpackage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions