@@ -46,34 +46,41 @@ const babelConfigForLegacy = {
46
46
build (
47
47
[
48
48
{
49
- file : resolve ( 'dist/vue-class-component.js' ) ,
50
- format : 'umd ' ,
49
+ file : resolve ( 'dist/vue-class-component.global. js' ) ,
50
+ format : 'iife ' ,
51
51
env : 'development' ,
52
52
} ,
53
53
{
54
- file : resolve ( 'dist/vue-class-component.min .js' ) ,
55
- format : 'umd ' ,
54
+ file : resolve ( 'dist/vue-class-component.global.prod .js' ) ,
55
+ format : 'iife ' ,
56
56
env : 'production' ,
57
+ minify : true ,
57
58
} ,
58
59
{
59
- file : resolve ( 'dist/vue-class-component.common .js' ) ,
60
+ file : resolve ( 'dist/vue-class-component.cjs .js' ) ,
60
61
format : 'cjs' ,
61
62
} ,
62
63
{
63
- file : resolve ( 'dist/vue-class-component.esm.js' ) ,
64
+ file : resolve ( 'dist/vue-class-component.esm-bundler .js' ) ,
64
65
format : 'esm' ,
65
66
} ,
66
67
{
67
- file : resolve ( 'dist/vue-class-component.esm. browser.js' ) ,
68
+ file : resolve ( 'dist/vue-class-component.esm- browser.js' ) ,
68
69
format : 'esm' ,
69
70
env : 'development' ,
70
71
} ,
71
72
{
72
- file : resolve ( 'dist/vue-class-component.esm. browser.min .js' ) ,
73
+ file : resolve ( 'dist/vue-class-component.esm- browser.prod .js' ) ,
73
74
format : 'esm' ,
74
75
env : 'production' ,
76
+ minify : true ,
75
77
} ,
76
- ] . map ( genConfig )
78
+ ] . map ( ( options ) => {
79
+ return {
80
+ config : genConfig ( options ) ,
81
+ options,
82
+ }
83
+ } )
77
84
) . catch ( ( ) => {
78
85
process . exit ( 1 )
79
86
} )
@@ -89,6 +96,11 @@ function genConfig(opts) {
89
96
? babelConfigForModern
90
97
: babelConfigForLegacy
91
98
) ,
99
+ replace ( {
100
+ __DEV__ : opts . env
101
+ ? JSON . stringify ( opts . env === 'development' )
102
+ : "process.env.NODE_ENV !== 'production'" ,
103
+ } ) ,
92
104
] ,
93
105
} ,
94
106
output : {
@@ -103,22 +115,15 @@ function genConfig(opts) {
103
115
} ,
104
116
}
105
117
106
- if ( opts . env ) {
107
- config . input . plugins . unshift (
108
- replace ( {
109
- 'process.env.NODE_ENV' : JSON . stringify ( opts . env ) ,
110
- } )
111
- )
112
- }
113
-
114
118
return config
115
119
}
116
120
117
121
function build ( builds ) {
118
122
let built = 0
119
123
const total = builds . length
120
124
const next = ( ) => {
121
- return buildEntry ( builds [ built ] )
125
+ const { config, options } = builds [ built ]
126
+ return buildEntry ( config , options )
122
127
. then ( ( ) => {
123
128
built ++
124
129
if ( built < total ) {
@@ -134,14 +139,14 @@ function build(builds) {
134
139
return next ( )
135
140
}
136
141
137
- function buildEntry ( { input, output } ) {
138
- const isProd = / m i n \. j s $ / . test ( output . file )
142
+ function buildEntry ( { input, output } , options ) {
143
+ const isMinify = options . minify
139
144
return rollup
140
145
. rollup ( input )
141
146
. then ( ( bundle ) => bundle . generate ( output ) )
142
147
. then ( ( result ) => {
143
148
const { code } = result . output [ 0 ]
144
- if ( isProd ) {
149
+ if ( isMinify ) {
145
150
const minified = uglify . minify ( code , {
146
151
output : {
147
152
preamble : output . banner ,
0 commit comments