File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
packages/webpack/src/utils Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 11import {
2- checkFilesDoNotExist ,
32 checkFilesExist ,
43 cleanupProject ,
54 newProject ,
5+ readFile ,
66 runCLI ,
77 runCLIAsync ,
88 tmpProjPath ,
99 uniq ,
1010 updateFile ,
1111} from '@nrwl/e2e/utils' ;
1212import { execSync } from 'child_process' ;
13+ import { read } from 'fs-extra' ;
1314
1415describe ( 'Node Applications + webpack' , ( ) => {
1516 beforeEach ( ( ) => newProject ( ) ) ;
@@ -23,13 +24,29 @@ describe('Node Applications + webpack', () => {
2324
2425 checkFilesExist ( `apps/${ app } /webpack.config.js` ) ;
2526
26- updateFile ( `apps/${ app } /src/main.ts` , `console.log('Hello World!');` ) ;
27+ updateFile (
28+ `apps/${ app } /src/main.ts` ,
29+ `
30+ function foo(x: string) {
31+ return "foo " + x;
32+ };
33+ console.log(foo("bar"));
34+ `
35+ ) ;
2736 await runCLIAsync ( `build ${ app } ` ) ;
2837
2938 checkFilesExist ( `dist/apps/${ app } /main.js` ) ;
39+ // no optimization by default
40+ const content = readFile ( `dist/apps/${ app } /main.js` ) ;
41+ expect ( content ) . toContain ( 'console.log(foo("bar"))' ) ;
42+
3043 const result = execSync ( `node dist/apps/${ app } /main.js` , {
3144 cwd : tmpProjPath ( ) ,
3245 } ) . toString ( ) ;
33- expect ( result ) . toMatch ( / H e l l o W o r l d ! / ) ;
46+ expect ( result ) . toMatch ( / f o o b a r / ) ;
47+
48+ await runCLIAsync ( `build ${ app } --optimization` ) ;
49+ const optimizedContent = readFile ( `dist/apps/${ app } /main.js` ) ;
50+ expect ( optimizedContent ) . toContain ( 'console.log("foo "+"bar")' ) ;
3451 } , 300_000 ) ;
3552} ) ;
Original file line number Diff line number Diff line change @@ -185,7 +185,10 @@ export function withNx(opts?: { skipTypeChecking?: boolean }) {
185185 optimization : {
186186 ...config . optimization ,
187187 sideEffects : true ,
188- minimize : ! ! options . optimization ,
188+ minimize :
189+ typeof options . optimization === 'object'
190+ ? ! ! options . optimization . scripts
191+ : ! ! options . optimization ,
189192 minimizer : [
190193 options . compiler !== 'swc'
191194 ? new TerserPlugin ( {
You can’t perform that action at this time.
0 commit comments