nwjs-builder-phoenix icon indicating copy to clipboard operation
nwjs-builder-phoenix copied to clipboard

Excludes have no effect on build

Open TheJaredWilcurt opened this issue 7 years ago • 2 comments

This is a simplified version of my package.json:

{
  "scripts": {
    "postinstall": "node postinstall.js",
    "build": "build --concurrent --tasks win-x86,linux-x86,linux-x64,mac-x64 --mirror https://dl.nwjs.io/ .",
  },
  "window": {
    "icon": "assets/icon.png"
  },
  "chromium-args": "--load-extension='./node_modules/vue-devtools/shells/chrome'",
  "build": {
    "nwVersion": "latest",
    "nwFlavor": "normal",
    "targets": [
      "zip",
      "nsis7z"
    ],
    "excludes": [
      "postinstall.js",
      "package-lock.json",
      "assets/*",
      "src/sass/*"
    ],
    "strippedProperties": [
      "chromium-args",
      "scripts",
      "devDependencies",
      "build"
    ],
    "win": {
      "icon": "assets/icon.ico"
    },
    "mac": {
      "icon": "assets/icon.icns"
    },
    "nsis": {
      "icon": "assets/icon.ico",
      "unIcon": "assets/icon.ico",
      "languages": [
        "English"
      ],
      "diffUpdaters": false,
      "hashCalculation": true
    }
  }
}

The problem is that I am completely removing sections via the strippedProperties/excludes, but they are only done after an npm install is performed for a platform. Specifically I am stripping the "scripts" section, which contains a "postinstall" script, and I'm excluding the "postinstall.js" file from the build. And yet the dist folder with my builds includes a large folder that is generated from the postinstall.js script. The postinstall.js file is not in the output folder, and the strippedProperties have been removed, but obviously it did this after the npm install and postinstall had completed.

This results in the builds taking much longer and being considerably larger than they should be.

TheJaredWilcurt avatar Jul 01 '18 17:07 TheJaredWilcurt

Hey there!

Know I'm resurrecting this from the grave, but it may help someone else. I was also running into this issue recently.

I found that adding the glob pattern '**/' before any file I wanted excluded worked to exclude, if I didn't, it added the file. Also, if I want to exclude a directory, I used '**/<directory_name>/**' and the directory is excluded.

For example:

    "excludes": [
      "**/postinstall.js",
      "**/package-lock.json",
      "**/assets/**",
      "**/src/sass/**"
    ],

Hope it helps!

tonetechnician avatar Jun 19 '19 09:06 tonetechnician

Doesn't work for me, even if I put '**/' before my filenames. If my package.json includes the following, my dist directory still includes all of the excluded files.

    "build": {
      "nwVersion": "0.40.2",
      "excludes": [ "README.md", "yarn.lock", "node_modules", "public", "src" ]
    },

sysrage avatar Sep 07 '19 02:09 sysrage