@@ -20,21 +20,49 @@ const resolve = _path => path.resolve(__dirname, '../', _path)
2020
2121build ( [
2222 {
23- dest : resolve ( 'dist/vue-class-component.js' ) ,
23+ file : resolve ( 'dist/vue-class-component.js' ) ,
2424 format : 'umd' ,
2525 env : 'development'
2626 } ,
2727 {
28- dest : resolve ( 'dist/vue-class-component.min.js' ) ,
28+ file : resolve ( 'dist/vue-class-component.min.js' ) ,
2929 format : 'umd' ,
3030 env : 'production'
3131 } ,
3232 {
33- dest : resolve ( 'dist/vue-class-component.common.js' ) ,
33+ file : resolve ( 'dist/vue-class-component.common.js' ) ,
3434 format : 'cjs'
3535 }
3636] . map ( genConfig ) )
3737
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+
3866function build ( builds ) {
3967 let built = 0
4068 const total = builds . length
@@ -50,45 +78,23 @@ function build (builds) {
5078 next ( )
5179}
5280
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+ } )
9298}
9399
94100function write ( dest , code , zip ) {
0 commit comments