From 903f3a2241a80671e7fce46c8a9ccae408fafe52 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Thu, 14 Jul 2022 15:43:07 +0100 Subject: [PATCH] Prevent packaging unneeded dependency files (#2303) * Prevent packaging unneeded dependency files * Exclude even more dependency files from being packaged --- _scripts/build.js | 22 +++++++++++++++++++++- _scripts/webpack.main.config.js | 11 +++++++---- _scripts/webpack.renderer.config.js | 14 +++++++++----- _scripts/webpack.web.config.js | 11 +++++++---- _scripts/webpack.workers.config.js | 2 +- package.json | 2 +- 6 files changed, 46 insertions(+), 16 deletions(-) diff --git a/_scripts/build.js b/_scripts/build.js index 7d92b13b..5bea792b 100644 --- a/_scripts/build.js +++ b/_scripts/build.js @@ -53,7 +53,27 @@ const config = { ] } ], - files: ['_icons/iconColor.*', 'icon.svg', './dist/**/*', '!./dist/web/**/*'], + files: [ + '_icons/iconColor.*', + 'icon.svg', + './dist/**/*', + '!dist/web/*', + '!**/node_modules/**/.*', + '!**/{.github,Jenkinsfile}', + '!**/{CHANGES.md,CODE_OF_CONDUCT.md,CONTRIBUTING.md,CONTRIBUTION.md,DEVELOPMENT.md,docs,docs.md,docs.mli,examples,History.md,HISTORY.md,index.html,README.md,TODO.md,UPGRADE_GUIDE.md,UPGRADING.md}', + '!**/{commitlint.config.js,.editorconfig,.eslintignore,.eslintrc.{js,yml},.gitmodules,.huskyrc,.lintstagedrc,.nvmrc,.nycrc{,.json},.prettierrc{,.yaml},tslint.json}', + '!**/{.babelrc,bower.json,Gruntfile.js,Makefile,.npmrc.proregistry,rollup.config.js,.tm_properties,.tool-versions,tsconfig.json,webpack.config.js}', + '!**/*.{{,c,m}js,min,ts}.map', + '!**/*.d.ts', + + // only exclude the src directory for specific packages + // as some of them have their dist code in there and we don't want to exclude those + '!**/node_modules/{@fortawesome/vue-fontawesome,agent-base,jquery,localforage,m3u8-parser,marked,mpd-parser,performance-now,video.js,vue,vue-i18n,vue-router}/src/*', + '!**/node_modules/**/{bin,man,scripts}/*', + '!**/node_modules/jquery/dist/jquery.slim*.js', + '!**/node_modules/video.js/dist/{alt/*,video.js}', + '!**/node_modules/@videojs/*/src' + ], dmg: { contents: [ { diff --git a/_scripts/webpack.main.config.js b/_scripts/webpack.main.config.js index c87c3cbb..d7316fd7 100644 --- a/_scripts/webpack.main.config.js +++ b/_scripts/webpack.main.config.js @@ -23,7 +23,7 @@ const config = { module: { rules: [ { - test: /\.(j|t)s$/, + test: /\.js$/, use: 'babel-loader', exclude: /node_modules/, }, @@ -76,21 +76,24 @@ if (isDevMode) { from: path.join(__dirname, '../static'), to: path.join(__dirname, '../dist/web/static'), globOptions: { - ignore: ['.*', 'pwabuilder-sw.js'], + dot: true, + ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], }, }, { from: path.join(__dirname, '../_icons'), to: path.join(__dirname, '../dist/_icons'), globOptions: { - ignore: ['.*'], + dot: true, + ignore: ['**/.*'], }, }, { from: path.join(__dirname, '../src/renderer/assets/img'), to: path.join(__dirname, '../dist/images'), globOptions: { - ignore: ['.*'], + dot: true, + ignore: ['**/.*'], }, }, ] diff --git a/_scripts/webpack.renderer.config.js b/_scripts/webpack.renderer.config.js index e8da4179..4f73ce06 100644 --- a/_scripts/webpack.renderer.config.js +++ b/_scripts/webpack.renderer.config.js @@ -37,7 +37,7 @@ const config = { module: { rules: [ { - test: /\.(j|t)s$/, + test: /\.js$/, use: 'babel-loader', exclude: /node_modules/, }, @@ -165,28 +165,32 @@ if (isDevMode) { from: path.join(__dirname, '../static'), to: path.join(__dirname, '../dist/web/static'), globOptions: { - ignore: ['.*', 'pwabuilder-sw.js'], + dot: true, + ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], }, }, { from: path.join(__dirname, '../static'), to: path.join(__dirname, '../dist/static'), globOptions: { - ignore: ['.*', 'pwabuilder-sw.js'], + dot: true, + ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], }, }, { from: path.join(__dirname, '../_icons'), to: path.join(__dirname, '../dist/web/_icons'), globOptions: { - ignore: ['.*'], + dot: true, + ignore: ['**/.*'], }, }, { from: path.join(__dirname, '../src/renderer/assets/img'), to: path.join(__dirname, '../dist/web/images'), globOptions: { - ignore: ['.*'], + dot: true, + ignore: ['**/.*'], }, }, ] diff --git a/_scripts/webpack.web.config.js b/_scripts/webpack.web.config.js index a95913d5..1b15f319 100644 --- a/_scripts/webpack.web.config.js +++ b/_scripts/webpack.web.config.js @@ -23,7 +23,7 @@ const config = { module: { rules: [ { - test: /\.(j|t)s$/, + test: /\.js$/, use: 'babel-loader', exclude: /node_modules/, }, @@ -163,21 +163,24 @@ if (isDevMode) { from: path.join(__dirname, '../static'), to: path.join(__dirname, '../dist/web/static'), globOptions: { - ignore: ['.*', 'pwabuilder-sw.js'], + dot: true, + ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], }, }, { from: path.join(__dirname, '../_icons'), to: path.join(__dirname, '../dist/web/_icons'), globOptions: { - ignore: ['.*'], + dot: true, + ignore: ['**/.*'], }, }, { from: path.join(__dirname, '../src/renderer/assets/img'), to: path.join(__dirname, '../dist/web/images'), globOptions: { - ignore: ['.*'], + dot: true, + ignore: ['**/.*'], }, }, ] diff --git a/_scripts/webpack.workers.config.js b/_scripts/webpack.workers.config.js index 7b6bb842..7ca42754 100644 --- a/_scripts/webpack.workers.config.js +++ b/_scripts/webpack.workers.config.js @@ -26,7 +26,7 @@ const config = { module: { rules: [ { - test: /\.(j|t)s$/, + test: /\.js$/, use: 'babel-loader', exclude: /node_modules/, }, diff --git a/package.json b/package.json index 63e793ad..daf4feac 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build-release": "node _scripts/build.js", "build-release:arm64": "node _scripts/build.js arm64", "build-release:arm32": "node _scripts/build.js arm32", - "clean": "rimraf build/ dashFiles/ dist/ storyboards/", + "clean": "rimraf build/ static/dashFiles/ dist/ static/storyboards/", "debug": "run-s rebuild:electron debug-runner", "debug-runner": "node _scripts/dev-runner.js --remote-debug", "dev": "run-s rebuild:electron dev-runner",