@@ -43,11 +43,12 @@ const createEnvironmentHash = require('./webpack/persistentCache/createEnvironme
43
43
const SpeedMeasureWebpackPlugin = require ( 'speed-measure-webpack-plugin' ) ;
44
44
const FilterWarningsPlugin = require ( 'webpack-filter-warnings-plugin' ) ;
45
45
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');
51
52
52
53
// iModel.js change to support using the fast-sass-loader instead of sass-loader.
53
54
// 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';
63
64
64
65
const shouldMinify = process . env . DISABLE_TERSER !== 'true' ;
65
66
66
- const disableNewAssetCopy = process . env . DISABLE_NEW_ASSET_COPY === 'true' ;
67
-
68
67
// End iModel.js Changes block
69
68
70
69
// Source maps are resource heavy and can cause out of memory issue for large source files.
@@ -287,6 +286,23 @@ module.exports = function (webpackEnv) {
287
286
? fastSassLoaderConfig
288
287
: 'sass-loader' ;
289
288
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
+
290
306
const rawConfig = {
291
307
target : [ 'browserslist' ] ,
292
308
mode : isEnvProduction ? 'production' : isEnvDevelopment && 'development' ,
@@ -436,7 +452,8 @@ module.exports = function (webpackEnv) {
436
452
} ,
437
453
plugins : [
438
454
// 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
+
440
457
// Prevents users from importing files from outside of src/ (or node_modules/).
441
458
// This often causes confusion because we only process files within src/ with babel.
442
459
// 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) {
749
766
// NOTE: iModel.js specific plugin to copy a set of static resources from the node_modules
750
767
// directory of each dependent package into the 'build/public' directory.
751
768
// 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 } ) ,
755
770
756
771
// NOTE: FilterWarningsPlugin is used to ignore warning coming from sourcemaps
757
772
new FilterWarningsPlugin ( { exclude : / F a i l e d t o p a r s e s o u r c e m a p / } ) ,
0 commit comments