File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
packages/@angular/cli/models/webpack-configs Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,12 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
99
99
// specify a configuration flag.
100
100
// Also prevent writing outside the project path. That is not overridable.
101
101
const fullOutputPath = path . resolve ( buildOptions . outputPath , asset . output ) ;
102
- if ( ! fullOutputPath . startsWith ( projectRoot ) ) {
103
- const message = 'An asset cannot be written to a location outside the project.' ;
104
- throw new SilentError ( message ) ;
105
- }
106
102
if ( ! fullOutputPath . startsWith ( path . resolve ( buildOptions . outputPath ) ) ) {
103
+ if ( ! fullOutputPath . startsWith ( projectRoot ) ) {
104
+ const message = 'An asset cannot be written to a location outside the project.' ;
105
+ throw new SilentError ( message ) ;
106
+ }
107
+
107
108
if ( ! asset . allowOutsideOutDir ) {
108
109
const message = 'An asset cannot be written to a location outside of the output path. '
109
110
+ 'You can override this message by setting the `allowOutsideOutDir` '
Original file line number Diff line number Diff line change @@ -55,6 +55,21 @@ export default function () {
55
55
} ) )
56
56
. then ( ( ) => expectToFail ( ( ) => ng ( 'build' ) ) )
57
57
58
+ // This asset will not fail with the exception above.
59
+ . then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
60
+ const app = configJson [ 'apps' ] [ 0 ] ;
61
+ app [ 'outDir' ] = '../../temp' ;
62
+ app [ 'assets' ] = [
63
+ { 'glob' : '**/*' , 'input' : '../node_modules/some-package/' , 'output' : '../../temp' ,
64
+ 'allowOutsideOutDir' : true }
65
+ ] ;
66
+ } ) )
67
+ . then ( ( ) => ng ( 'build' ) )
68
+ . then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
69
+ const app = configJson [ 'apps' ] [ 0 ] ;
70
+ app [ 'outDir' ] = 'dist' ;
71
+ } )
72
+
58
73
// This asset should also fail from reading from outside the project.
59
74
. then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
60
75
const app = configJson [ 'apps' ] [ 0 ] ;
You can’t perform that action at this time.
0 commit comments