@@ -20,21 +20,49 @@ const resolve = _path => path.resolve(__dirname, '../', _path)
20
20
21
21
build ( [
22
22
{
23
- dest : resolve ( 'dist/vue-class-component.js' ) ,
23
+ file : resolve ( 'dist/vue-class-component.js' ) ,
24
24
format : 'umd' ,
25
25
env : 'development'
26
26
} ,
27
27
{
28
- dest : resolve ( 'dist/vue-class-component.min.js' ) ,
28
+ file : resolve ( 'dist/vue-class-component.min.js' ) ,
29
29
format : 'umd' ,
30
30
env : 'production'
31
31
} ,
32
32
{
33
- dest : resolve ( 'dist/vue-class-component.common.js' ) ,
33
+ file : resolve ( 'dist/vue-class-component.common.js' ) ,
34
34
format : 'cjs'
35
35
}
36
36
] . map ( genConfig ) )
37
37
38
+ function genConfig ( opts ) {
39
+ const config = {
40
+ input : {
41
+ input : resolve ( 'lib/index.js' ) ,
42
+ external : [ 'vue' ] ,
43
+ plugins : [ ]
44
+ } ,
45
+ output : {
46
+ file : opts . file ,
47
+ format : opts . format ,
48
+ banner,
49
+ name : 'VueClassComponent' ,
50
+ exports : 'named' ,
51
+ globals : {
52
+ vue : 'Vue'
53
+ }
54
+ }
55
+ }
56
+
57
+ if ( opts . env ) {
58
+ config . input . plugins . unshift ( replace ( {
59
+ 'process.env.NODE_ENV' : JSON . stringify ( opts . env )
60
+ } ) )
61
+ }
62
+
63
+ return config
64
+ }
65
+
38
66
function build ( builds ) {
39
67
let built = 0
40
68
const total = builds . length
@@ -50,45 +78,23 @@ function build (builds) {
50
78
next ( )
51
79
}
52
80
53
- function genConfig ( opts ) {
54
- const config = {
55
- entry : resolve ( 'lib/index.js' ) ,
56
- dest : opts . dest ,
57
- format : opts . format ,
58
- banner,
59
- moduleName : 'VueClassComponent' ,
60
- exports : 'named' ,
61
- external : [ 'vue' ] ,
62
- globals : {
63
- vue : 'Vue'
64
- } ,
65
- plugins : [ ]
66
- }
67
-
68
- if ( opts . env ) {
69
- config . plugins . unshift ( replace ( {
70
- 'process.env.NODE_ENV' : JSON . stringify ( opts . env )
71
- } ) )
72
- }
73
-
74
- return config
75
- }
76
-
77
- function buildEntry ( config ) {
78
- const isProd = / m i n \. j s $ / . test ( config . dest )
79
- return rollup . rollup ( config ) . then ( bundle => {
80
- const code = bundle . generate ( config ) . code
81
- if ( isProd ) {
82
- var minified = uglify . minify ( code , {
83
- output : {
84
- preamble : config . banner
85
- }
86
- } ) . code
87
- return write ( config . dest , minified , true )
88
- } else {
89
- return write ( config . dest , code )
90
- }
91
- } )
81
+ function buildEntry ( { input, output } ) {
82
+ const isProd = / m i n \. j s $ / . test ( output . file )
83
+ return rollup . rollup ( input )
84
+ . then ( bundle => bundle . generate ( output ) )
85
+ . then ( ( { code } ) => {
86
+ if ( isProd ) {
87
+ var minified = uglify . minify ( code , {
88
+ output : {
89
+ preamble : output . banner ,
90
+ ascii_only : true
91
+ }
92
+ } ) . code
93
+ return write ( output . file , minified , true )
94
+ } else {
95
+ return write ( output . file , code )
96
+ }
97
+ } )
92
98
}
93
99
94
100
function write ( dest , code , zip ) {
0 commit comments