1
1
import {
2
2
writeMultipleFiles ,
3
3
expectFileToMatch ,
4
- appendToFile
4
+ appendToFile ,
5
+ expectFileToExist
5
6
} from '../../utils/fs' ;
6
7
import { ng } from '../../utils/process' ;
7
8
import { updateJsonFile } from '../../utils/project' ;
9
+ import { expectToFail } from '../../utils/utils' ;
8
10
import { oneLineTrim } from 'common-tags' ;
9
11
10
12
export default function ( ) {
@@ -16,6 +18,8 @@ export default function () {
16
18
'src/pre-rename-lazy-script.js' : 'console.log(\'pre-rename-lazy-script\');' ,
17
19
'src/common-entry-script.js' : 'console.log(\'common-entry-script\');' ,
18
20
'src/common-entry-style.css' : '.common-entry-style { color: red }' ,
21
+ 'src/development-script.js' : 'console.log(\'development-script\');' ,
22
+ 'src/production-script.js' : 'console.log(\'production-script\');' ,
19
23
} )
20
24
. then ( ( ) => appendToFile ( 'src/main.ts' , 'import \'./string-script.js\';' ) )
21
25
. then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
@@ -26,7 +30,9 @@ export default function () {
26
30
{ input : 'lazy-script.js' , lazy : true } ,
27
31
{ input : 'pre-rename-script.js' , output : 'renamed-script' } ,
28
32
{ input : 'pre-rename-lazy-script.js' , output : 'renamed-lazy-script' , lazy : true } ,
29
- { input : 'common-entry-script.js' , output : 'common-entry' }
33
+ { input : 'common-entry-script.js' , output : 'common-entry' } ,
34
+ { input : 'development-script.js' , output : 'development-script' , env : 'dev' } ,
35
+ { input : 'production-script.js' , output : 'production-script' , env : 'prod' } ,
30
36
] ;
31
37
app [ 'styles' ] = [ { input : 'common-entry-style.css' , output : 'common-entry' } ] ;
32
38
} ) )
@@ -39,6 +45,8 @@ export default function () {
39
45
. then ( ( ) => expectFileToMatch ( 'dist/renamed-lazy-script.bundle.js' , 'pre-rename-lazy-script' ) )
40
46
. then ( ( ) => expectFileToMatch ( 'dist/common-entry.bundle.js' , 'common-entry-script' ) )
41
47
. then ( ( ) => expectFileToMatch ( 'dist/common-entry.bundle.css' , '.common-entry-style' ) )
48
+ . then ( ( ) => expectFileToMatch ( 'dist/development-script.bundle.js' , 'development-script' ) )
49
+ . then ( ( ) => expectToFail ( ( ) => expectFileToExist ( 'dist/production-script.bundle.js' ) ) )
42
50
// index.html lists the right bundles
43
51
. then ( ( ) => expectFileToMatch ( 'dist/index.html' , oneLineTrim `
44
52
<link href="common-entry.bundle.css" rel="stylesheet"/>
@@ -49,6 +57,7 @@ export default function () {
49
57
<script type="text/javascript" src="scripts.bundle.js"></script>
50
58
<script type="text/javascript" src="renamed-script.bundle.js"></script>
51
59
<script type="text/javascript" src="common-entry.bundle.js"></script>
60
+ <script type="text/javascript" src="development-script.bundle.js"></script>
52
61
<script type="text/javascript" src="vendor.bundle.js"></script>
53
62
<script type="text/javascript" src="main.bundle.js"></script>
54
63
` ) )
0 commit comments