From 1034ba6dc5af23557c4123c72521744c621102ab Mon Sep 17 00:00:00 2001 From: Arun George Date: Thu, 15 Apr 2021 17:11:54 -0400 Subject: [PATCH 1/4] use copy-webpack-plugin to deliver all static assets. this also works with the dev server, so strings should finally be localized there! --- .../react-scripts/config/webpack.config.js | 32 ++++++++++++++++--- packages/react-scripts/package.json | 1 + 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index c62a864dd05..665dcfb2e86 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -47,9 +47,10 @@ const FilterWarningsPlugin = require('webpack-filter-warnings-plugin'); const { BanBackendImportsPlugin, IModeljsLibraryExportsPlugin, - CopyBentleyStaticResourcesPlugin, } = require('@bentley/webpack-tools-core'); +const CopyPlugin = require('copy-webpack-plugin'); + // iModel.js change to support using the fast-sass-loader instead of sass-loader. // This solves long build times on smaller machines attempting to build an app with // a large amount of sccs/sass files. @@ -412,7 +413,7 @@ module.exports = function(webpackEnv) { }, plugins: [ // Throw an error if @bentley/imodeljs-backend or src/backend/... files are imported. - new BanBackendImportsPlugin(path.join(paths.appSrc, "backend")), + new BanBackendImportsPlugin(path.join(paths.appSrc, 'backend')), // Adds support for installing with Plug'n'Play, leading to faster installs and adding // guards against forgotten dependencies and such. PnpWebpackPlugin, @@ -696,9 +697,32 @@ module.exports = function(webpackEnv) { new IModeljsLibraryExportsPlugin(), // NOTE: iModel.js specific plugin to copy a set of static resources from the node_modules - // directory of each dependent package into the 'lib/public' directory. + // directory of each dependent package into the 'build/public' directory. // Used for resources such as locales, which are defined by each consuming package. - new CopyBentleyStaticResourcesPlugin(['public'], true), + new CopyPlugin({ + patterns: [ + { + from: '**/public/**/*', + context: 'node_modules/@bentley', + noErrorOnMissing: true, + to({ absoluteFilename }) { + return Promise.resolve( + /(public\\)(.*)/.exec(absoluteFilename)[2] + ); + }, + }, + { + from: '**/public/**/*', + context: 'node_modules/@itwin', + noErrorOnMissing: true, + to({ absoluteFilename }) { + return Promise.resolve( + /(public\\)(.*)/.exec(absoluteFilename)[2] + ); + }, + }, + ], + }), // NOTE: FilterWarningsPlugin is used to ignore warning coming from sourcemaps new FilterWarningsPlugin({ exclude: /Failed to parse source map/ }), diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 630f3341314..57b05d71613 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -42,6 +42,7 @@ "babel-preset-react-app": "^9.1.2", "camelcase": "^5.3.1", "case-sensitive-paths-webpack-plugin": "2.3.0", + "copy-webpack-plugin": "^6.2.1", "css-loader": "3.4.2", "dotenv": "8.2.0", "dotenv-expand": "5.1.0", From 5f5846b6632bd3f4a6601dce7333c3b13b6315c7 Mon Sep 17 00:00:00 2001 From: Arun George Date: Thu, 15 Apr 2021 17:15:54 -0400 Subject: [PATCH 2/4] bump ver --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 57b05d71613..d6dad8d9ff4 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@bentley/react-scripts", - "version": "3.4.10", + "version": "3.4.11", "description": "iModel.js configuration and scripts for Create React App.", "repository": { "type": "git", From 1347d9a018fc9fc980fd6f9a9eeeb3a3617c3338 Mon Sep 17 00:00:00 2001 From: Arun George Date: Thu, 27 May 2021 17:17:07 -0400 Subject: [PATCH 3/4] pickup new CopyStaticAssetsPlugin from 2.16.1 --- .../react-scripts/config/webpack.config.js | 26 ++----------------- packages/react-scripts/package.json | 3 +-- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 665dcfb2e86..50077234d1e 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -46,6 +46,7 @@ const FilterWarningsPlugin = require('webpack-filter-warnings-plugin'); const { BanBackendImportsPlugin, + CopyStaticAssetsPlugin, IModeljsLibraryExportsPlugin, } = require('@bentley/webpack-tools-core'); @@ -699,30 +700,7 @@ module.exports = function(webpackEnv) { // NOTE: iModel.js specific plugin to copy a set of static resources from the node_modules // directory of each dependent package into the 'build/public' directory. // Used for resources such as locales, which are defined by each consuming package. - new CopyPlugin({ - patterns: [ - { - from: '**/public/**/*', - context: 'node_modules/@bentley', - noErrorOnMissing: true, - to({ absoluteFilename }) { - return Promise.resolve( - /(public\\)(.*)/.exec(absoluteFilename)[2] - ); - }, - }, - { - from: '**/public/**/*', - context: 'node_modules/@itwin', - noErrorOnMissing: true, - to({ absoluteFilename }) { - return Promise.resolve( - /(public\\)(.*)/.exec(absoluteFilename)[2] - ); - }, - }, - ], - }), + new CopyStaticAssetsPlugin({}), // NOTE: FilterWarningsPlugin is used to ignore warning coming from sourcemaps new FilterWarningsPlugin({ exclude: /Failed to parse source map/ }), diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index d6dad8d9ff4..a8dabd179e4 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -29,7 +29,7 @@ "types": "./lib/react-app.d.ts", "dependencies": { "@babel/core": "7.9.0", - "@bentley/webpack-tools-core": "^2.0.0", + "@bentley/webpack-tools-core": "^2.16.1", "@svgr/webpack": "4.3.3", "@typescript-eslint/eslint-plugin": "^4.1.1", "@typescript-eslint/parser": "^4.1.1", @@ -42,7 +42,6 @@ "babel-preset-react-app": "^9.1.2", "camelcase": "^5.3.1", "case-sensitive-paths-webpack-plugin": "2.3.0", - "copy-webpack-plugin": "^6.2.1", "css-loader": "3.4.2", "dotenv": "8.2.0", "dotenv-expand": "5.1.0", From a795cca21a85c27eed3c7c645248bfb8de4e7735 Mon Sep 17 00:00:00 2001 From: Arun George Date: Thu, 27 May 2021 17:18:55 -0400 Subject: [PATCH 4/4] forgot to remove old CopyWebpackPlugin --- packages/react-scripts/config/webpack.config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 50077234d1e..17b5bcc7ea2 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -50,8 +50,6 @@ const { IModeljsLibraryExportsPlugin, } = require('@bentley/webpack-tools-core'); -const CopyPlugin = require('copy-webpack-plugin'); - // iModel.js change to support using the fast-sass-loader instead of sass-loader. // This solves long build times on smaller machines attempting to build an app with // a large amount of sccs/sass files.