diff --git a/packages/node/src/utils/normalize.spec.ts b/packages/node/src/utils/normalize.spec.ts index 49f827268eb6d..215132af4ce58 100644 --- a/packages/node/src/utils/normalize.spec.ts +++ b/packages/node/src/utils/normalize.spec.ts @@ -61,7 +61,7 @@ describe('normalizeBuildOptions', () => { assets: [ 'apps/nodeapp/src/assets', { - input: '/outsideroot', + input: 'outsideproj', output: 'output', glob: '**/*', ignore: ['**/*.json'] @@ -78,7 +78,7 @@ describe('normalizeBuildOptions', () => { glob: '**/*' }, { - input: '/outsideroot', + input: '/root/outsideproj', output: 'output', glob: '**/*', ignore: ['**/*.json'] diff --git a/packages/node/src/utils/normalize.ts b/packages/node/src/utils/normalize.ts index c0398470dd146..a0a74da9c5d8c 100644 --- a/packages/node/src/utils/normalize.ts +++ b/packages/node/src/utils/normalize.ts @@ -62,8 +62,12 @@ function normalizeAssets( 'An asset cannot be written to a location outside of the output path.' ); } + + const assetPath = normalize(asset.input); + const resolvedAssetPath = resolve(root, assetPath); return { ...asset, + input: resolvedAssetPath, // Now we remove starting slash to make Webpack place it from the output root. output: asset.output.replace(/^\//, '') }; diff --git a/packages/web/src/utils/normalize.spec.ts b/packages/web/src/utils/normalize.spec.ts index cadbd6bd6f489..8d4be618f625c 100644 --- a/packages/web/src/utils/normalize.spec.ts +++ b/packages/web/src/utils/normalize.spec.ts @@ -57,7 +57,7 @@ describe('normalizeBuildOptions', () => { assets: [ 'apps/nodeapp/src/assets', { - input: '/outsideroot', + input: 'outsideproj', output: 'output', glob: '**/*', ignore: ['**/*.json'] @@ -74,7 +74,7 @@ describe('normalizeBuildOptions', () => { glob: '**/*' }, { - input: '/outsideroot', + input: '/root/outsideproj', output: 'output', glob: '**/*', ignore: ['**/*.json'] diff --git a/packages/web/src/utils/normalize.ts b/packages/web/src/utils/normalize.ts index ad2df66021efb..d0f01258987de 100644 --- a/packages/web/src/utils/normalize.ts +++ b/packages/web/src/utils/normalize.ts @@ -62,8 +62,12 @@ function normalizeAssets( 'An asset cannot be written to a location outside of the output path.' ); } + + const assetPath = normalize(asset.input); + const resolvedAssetPath = resolve(root, assetPath); return { ...asset, + input: resolvedAssetPath, // Now we remove starting slash to make Webpack place it from the output root. output: asset.output.replace(/^\//, '') };