Skip to content

Commit

Permalink
fix(nx): fix assets option object input
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored and vsavkin committed Jul 17, 2019
1 parent f1f0663 commit 93c000d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/node/src/utils/normalize.spec.ts
Expand Up @@ -61,7 +61,7 @@ describe('normalizeBuildOptions', () => {
assets: [
'apps/nodeapp/src/assets',
{
input: '/outsideroot',
input: 'outsideproj',
output: 'output',
glob: '**/*',
ignore: ['**/*.json']
Expand All @@ -78,7 +78,7 @@ describe('normalizeBuildOptions', () => {
glob: '**/*'
},
{
input: '/outsideroot',
input: '/root/outsideproj',
output: 'output',
glob: '**/*',
ignore: ['**/*.json']
Expand Down
4 changes: 4 additions & 0 deletions packages/node/src/utils/normalize.ts
Expand Up @@ -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(/^\//, '')
};
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/utils/normalize.spec.ts
Expand Up @@ -57,7 +57,7 @@ describe('normalizeBuildOptions', () => {
assets: [
'apps/nodeapp/src/assets',
{
input: '/outsideroot',
input: 'outsideproj',
output: 'output',
glob: '**/*',
ignore: ['**/*.json']
Expand All @@ -74,7 +74,7 @@ describe('normalizeBuildOptions', () => {
glob: '**/*'
},
{
input: '/outsideroot',
input: '/root/outsideproj',
output: 'output',
glob: '**/*',
ignore: ['**/*.json']
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/utils/normalize.ts
Expand Up @@ -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(/^\//, '')
};
Expand Down

0 comments on commit 93c000d

Please sign in to comment.