From 9b804f4ed46c22a0859fc1646ef1a40b694c6f88 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 22 Aug 2020 03:23:03 +0200 Subject: [PATCH] Speed up licenses.txt build during development, add additionalModules (#12510) - Emit static string for licenses.txt during development for faster builds - Manually add @primer/octicons to licenses.txt because it's never directy imported. Co-authored-by: Lauris BH Co-authored-by: techknowlogick --- package-lock.json | 5 +++++ package.json | 1 + webpack.config.js | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d35d615616..282e55e3f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1505,6 +1505,11 @@ "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", "dev": true }, + "add-asset-webpack-plugin": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/add-asset-webpack-plugin/-/add-asset-webpack-plugin-1.0.0.tgz", + "integrity": "sha512-Pg6UTxMPmVpGobpBTBmTO54aKvZfnY/rm7YvY86BXv4toE8I29ail6kAzsf0GyEMK6MgvGVDxs4IZXPTCUooNw==" + }, "aggregate-error": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", diff --git a/package.json b/package.json index 983ec0edcf..3b5ba482ee 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@babel/runtime": "7.11.2", "@claviska/jquery-minicolors": "2.3.5", "@primer/octicons": "10.0.0", + "add-asset-webpack-plugin": "1.0.0", "babel-loader": "8.1.0", "clipboard": "2.0.6", "core-js": "3.6.5", diff --git a/webpack.config.js b/webpack.config.js index d7f0c83d8a..9a69c550f2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,6 @@ const fastGlob = require('fast-glob'); const wrapAnsi = require('wrap-ansi'); +const AddAssetPlugin = require('add-asset-webpack-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -273,7 +274,7 @@ module.exports = { new MonacoWebpackPlugin({ filename: 'js/monaco-[name].worker.js', }), - new LicenseWebpackPlugin({ + isProduction ? new LicenseWebpackPlugin({ outputFilename: 'js/licenses.txt', perChunkOutput: false, addBanner: false, @@ -281,6 +282,9 @@ module.exports = { modulesDirectories: [ resolve(__dirname, 'node_modules'), ], + additionalModules: [ + '@primer/octicons', + ].map((name) => ({name, directory: resolve(__dirname, `node_modules/${name}`)})), renderLicenses: (modules) => { const line = '-'.repeat(80); return modules.map((module) => { @@ -294,7 +298,7 @@ module.exports = { warnings: false, errors: true, }, - }), + }) : new AddAssetPlugin('js/licenses.txt', `Licenses are disabled during development`), ], performance: { hints: false,