@@ -4,6 +4,15 @@ const expect = require('chai').expect;
4
4
const angular = require ( '../../dist/rollup-plugin-angular.js' ) ;
5
5
const external = Object . keys ( require ( './../../package.json' ) . dependencies ) . concat ( [ 'fs' , 'path' ] ) ;
6
6
const colors = require ( 'colors' ) ;
7
+ const sass = require ( 'node-sass' ) ;
8
+ const cleanCSS = require ( 'clean-css' ) ;
9
+ const htmlMinifier = require ( 'html-minifier' ) ;
10
+ const cssmin = new cleanCSS ( ) ;
11
+ const htmlminOpts = {
12
+ caseSensitive : true ,
13
+ collapseWhitespace : true ,
14
+ removeComments : true
15
+ } ;
7
16
8
17
process . chdir ( 'test' ) ;
9
18
@@ -13,15 +22,20 @@ describe('rollup-plugin-angular', () => {
13
22
console . info ( `-------------------` ) ;
14
23
it ( 'should not have component.html file content loaded from comment' , ( ) => {
15
24
return rollup ( {
16
- entry : 'mochajs/component.js' ,
25
+ input : 'mochajs/component.js' ,
17
26
external : external ,
18
27
plugins : [
19
- angular ( )
28
+ angular ( {
29
+ replace : false
30
+ } )
20
31
]
21
32
} )
22
33
. then ( bundle => {
23
34
return bundle
24
- . generate ( { format : 'iife' , moduleName : 'component' } )
35
+ . generate ( {
36
+ format : 'umd' ,
37
+ name : 'component'
38
+ } )
25
39
. then ( generated => {
26
40
expect ( generated . code . includes ( `component.html content loaded` ) ) . to . equal ( false ) ;
27
41
assert . ok ( generated . code ) ;
@@ -31,15 +45,26 @@ describe('rollup-plugin-angular', () => {
31
45
32
46
it ( 'should have example-component.html file content loaded' , ( ) => {
33
47
return rollup ( {
34
- entry : 'mochajs/example-component.js' ,
48
+ input : 'mochajs/example-component.js' ,
35
49
external : external ,
36
50
plugins : [
37
- angular ( )
51
+ angular ( {
52
+ preprocessors : {
53
+ template : template => htmlMinifier . minify ( template , htmlminOpts ) ,
54
+ style : scss => {
55
+ const css = sass . renderSync ( { data : scss } ) . css ;
56
+ return cssmin . minify ( css ) . styles ;
57
+ } ,
58
+ }
59
+ } )
38
60
]
39
61
} )
40
62
. then ( bundle => {
41
63
return bundle
42
- . generate ( { format : 'umd' , moduleName : 'component' } )
64
+ . generate ( {
65
+ format : 'umd' ,
66
+ name : 'component'
67
+ } )
43
68
. then ( generated => {
44
69
expect ( generated . code . includes ( `blaah` ) ) . to . equal ( true ) ;
45
70
assert . ok ( generated . code ) ;
0 commit comments