Skip to content

Commit 2e2b1f8

Browse files
committed
comment out 4.x plugins for time being, got copy plugin to work with monorepos too!
1 parent eb74552 commit 2e2b1f8

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

packages/react-scripts/config/webpack.config.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ const createEnvironmentHash = require('./webpack/persistentCache/createEnvironme
4343
const SpeedMeasureWebpackPlugin = require('speed-measure-webpack-plugin');
4444
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
4545

46-
const {
47-
BanBackendImportsPlugin,
48-
CopyBentleyStaticResourcesPlugin,
49-
CopyStaticAssetsPlugin,
50-
} = require('@itwin/core-webpack-tools');
46+
const CopyPlugin = require("copy-webpack-plugin");
47+
// const {
48+
// BanBackendImportsPlugin,
49+
// CopyBentleyStaticResourcesPlugin,
50+
// CopyStaticAssetsPlugin,
51+
// } = require('@itwin/core-webpack-tools');
5152

5253
// iModel.js change to support using the fast-sass-loader instead of sass-loader.
5354
// This solves long build times on smaller machines attempting to build an app with
@@ -63,8 +64,6 @@ const shouldTranspileDeps = process.env.TRANSPILE_DEPS !== 'false';
6364

6465
const shouldMinify = process.env.DISABLE_TERSER !== 'true';
6566

66-
const disableNewAssetCopy = process.env.DISABLE_NEW_ASSET_COPY === 'true';
67-
6867
// End iModel.js Changes block
6968

7069
// Source maps are resource heavy and can cause out of memory issue for large source files.
@@ -287,6 +286,23 @@ module.exports = function (webpackEnv) {
287286
? fastSassLoaderConfig
288287
: 'sass-loader';
289288

289+
const copyPluginPatterns = Object.keys(require(paths.appPackageJson).dependencies)
290+
.filter(dependency => dependency.startsWith('@bentley') || dependency.startsWith('@itwin'))
291+
.map(dependency => {
292+
return {
293+
from: "**/public/**",
294+
noErrorOnMissing: true,
295+
context: path.dirname(require.resolve(`${dependency}/package.json`)),
296+
globOptions: {
297+
ignore: ["**/node_modules/**"],
298+
},
299+
to({ absoluteFilename }) {
300+
const regex = new RegExp("(public(?:\\\\|\/))(.*)");
301+
return regex.exec(absoluteFilename)[2];
302+
},
303+
};
304+
});
305+
290306
const rawConfig = {
291307
target: ['browserslist'],
292308
mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
@@ -436,7 +452,8 @@ module.exports = function (webpackEnv) {
436452
},
437453
plugins: [
438454
// Throw an error if @bentley/imodeljs-backend or src/backend/... files are imported.
439-
new BanBackendImportsPlugin(path.join(paths.appSrc, 'backend')),
455+
// new BanBackendImportsPlugin(path.join(paths.appSrc, 'backend')),
456+
440457
// Prevents users from importing files from outside of src/ (or node_modules/).
441458
// This often causes confusion because we only process files within src/ with babel.
442459
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
@@ -749,9 +766,7 @@ module.exports = function (webpackEnv) {
749766
// NOTE: iModel.js specific plugin to copy a set of static resources from the node_modules
750767
// directory of each dependent package into the 'build/public' directory.
751768
// Used for resources such as locales, which are defined by each consuming package.
752-
disableNewAssetCopy
753-
? new CopyBentleyStaticResourcesPlugin(['public'], true)
754-
: new CopyStaticAssetsPlugin({}),
769+
new CopyPlugin({ patterns: copyPluginPatterns }),
755770

756771
// NOTE: FilterWarningsPlugin is used to ignore warning coming from sourcemaps
757772
new FilterWarningsPlugin({ exclude: /Failed to parse source map/ }),

packages/react-scripts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bentley/react-scripts",
3-
"version": "5.0.0-dev.1",
3+
"version": "5.0.0-dev.2",
44
"description": "iTwin.js configuration and scripts for Create React App.",
55
"repository": {
66
"type": "git",
@@ -41,6 +41,7 @@
4141
"browserslist": "^4.18.1",
4242
"camelcase": "^6.2.1",
4343
"case-sensitive-paths-webpack-plugin": "^2.4.0",
44+
"copy-webpack-plugin": "^10.2.4",
4445
"css-loader": "^6.5.1",
4546
"css-minimizer-webpack-plugin": "^3.2.0",
4647
"dotenv": "^10.0.0",

0 commit comments

Comments
 (0)