@@ -4,11 +4,10 @@ import path from "path";
4
4
import vue from "rollup-plugin-vue" ;
5
5
import alias from "@rollup/plugin-alias" ;
6
6
import commonjs from "@rollup/plugin-commonjs" ;
7
+ import resolve from "@rollup/plugin-node-resolve" ;
7
8
import replace from "@rollup/plugin-replace" ;
8
- import babel from "rollup-plugin-babel" ;
9
- import postcss from "rollup-plugin-postcss" ;
9
+ import babel from "@rollup/plugin-babel" ;
10
10
import { terser } from "rollup-plugin-terser" ;
11
- import postcssLogical from "postcss-logical" ;
12
11
import minimist from "minimist" ;
13
12
14
13
// Get browserslist config and remove ie from es build targets
@@ -18,6 +17,11 @@ const esbrowserslist = fs
18
17
. split ( "\n" )
19
18
. filter ( ( entry ) => entry && entry . substring ( 0 , 2 ) !== "ie" ) ;
20
19
20
+ // Extract babel preset-env config, to combine with esbrowserslist
21
+ const babelPresetEnvConfig = require ( "../babel.config" ) . presets . filter (
22
+ ( entry ) => entry [ 0 ] === "@babel/preset-env"
23
+ ) [ 0 ] [ 1 ] ;
24
+
21
25
const argv = minimist ( process . argv . slice ( 2 ) ) ;
22
26
23
27
const projectRoot = path . resolve ( __dirname , ".." ) ;
@@ -27,25 +31,35 @@ const baseConfig = {
27
31
plugins : {
28
32
preVue : [
29
33
alias ( {
30
- resolve : [ ".js" , ".jsx" , ".ts" , ".tsx" , ".vue" ] ,
31
- entries : {
32
- "@" : path . resolve ( projectRoot , "src" ) ,
33
- } ,
34
+ entries : [
35
+ {
36
+ find : "@" ,
37
+ replacement : `${ path . resolve ( projectRoot , "src" ) } ` ,
38
+ } ,
39
+ ] ,
34
40
} ) ,
35
41
] ,
36
42
replace : {
43
+ preventAssignment : true ,
37
44
"process.env.NODE_ENV" : JSON . stringify ( "production" ) ,
38
- "process.env.ES_BUILD" : JSON . stringify ( "false " ) ,
45
+ "process.env.ES_BUILD" : JSON . stringify ( "true " ) ,
39
46
} ,
40
47
vue : {
41
48
css : true ,
42
49
template : {
43
50
isProduction : true ,
44
51
} ,
45
52
} ,
53
+ postVue : [
54
+ resolve ( {
55
+ extensions : [ ".js" , ".jsx" , ".ts" , ".tsx" , ".vue" ] ,
56
+ } ) ,
57
+ commonjs ( ) ,
58
+ ] ,
46
59
babel : {
47
60
exclude : "node_modules/**" ,
48
61
extensions : [ ".js" , ".jsx" , ".ts" , ".tsx" , ".vue" ] ,
62
+ babelHelpers : "bundled" ,
49
63
} ,
50
64
} ,
51
65
} ;
@@ -74,28 +88,26 @@ if (!argv.format || argv.format === "es") {
74
88
external,
75
89
output : {
76
90
file : "dist/esm.js" ,
77
- format : "es " ,
91
+ format : "esm " ,
78
92
exports : "named" ,
79
93
} ,
80
94
plugins : [
81
- replace ( {
82
- ...baseConfig . plugins . replace ,
83
- "process.env.ES_BUILD" : JSON . stringify ( "true" ) ,
84
- } ) ,
95
+ replace ( baseConfig . plugins . replace ) ,
85
96
...baseConfig . plugins . preVue ,
86
97
vue ( baseConfig . plugins . vue ) ,
98
+ ...baseConfig . plugins . postVue ,
87
99
babel ( {
88
100
...baseConfig . plugins . babel ,
89
101
presets : [
90
102
[
91
103
"@babel/preset-env" ,
92
104
{
105
+ ...babelPresetEnvConfig ,
93
106
targets : esbrowserslist ,
94
107
} ,
95
108
] ,
96
109
] ,
97
110
} ) ,
98
- commonjs ( ) ,
99
111
] ,
100
112
} ;
101
113
buildFormats . push ( esConfig ) ;
@@ -110,7 +122,7 @@ if (!argv.format || argv.format === "cjs") {
110
122
file : "dist/ssr.js" ,
111
123
format : "cjs" ,
112
124
name : "VueNotion" ,
113
- exports : "named " ,
125
+ exports : "auto " ,
114
126
globals,
115
127
} ,
116
128
plugins : [
@@ -123,8 +135,8 @@ if (!argv.format || argv.format === "cjs") {
123
135
optimizeSSR : true ,
124
136
} ,
125
137
} ) ,
138
+ ...baseConfig . plugins . postVue ,
126
139
babel ( baseConfig . plugins . babel ) ,
127
- commonjs ( ) ,
128
140
] ,
129
141
} ;
130
142
buildFormats . push ( umdConfig ) ;
@@ -138,16 +150,16 @@ if (!argv.format || argv.format === "iife") {
138
150
compact : true ,
139
151
file : "dist/min.js" ,
140
152
format : "iife" ,
141
- name : "VueNotion " ,
153
+ name : "VuteNotion " ,
142
154
exports : "named" ,
143
155
globals,
144
156
} ,
145
157
plugins : [
146
158
replace ( baseConfig . plugins . replace ) ,
147
159
...baseConfig . plugins . preVue ,
148
160
vue ( baseConfig . plugins . vue ) ,
161
+ ...baseConfig . plugins . postVue ,
149
162
babel ( baseConfig . plugins . babel ) ,
150
- commonjs ( ) ,
151
163
terser ( {
152
164
output : {
153
165
ecma : 5 ,
@@ -158,28 +170,5 @@ if (!argv.format || argv.format === "iife") {
158
170
buildFormats . push ( unpkgConfig ) ;
159
171
}
160
172
161
- if ( ! argv . format || argv . format === "postcss" ) {
162
- const postCssConfig = {
163
- input : "build/postcss.js" ,
164
- output : {
165
- format : "es" ,
166
- file : "dist/styles.ignore" ,
167
- } ,
168
- plugins : [
169
- postcss ( {
170
- extract : true ,
171
- minimize : true ,
172
- plugins : [ postcssLogical ( ) ] ,
173
- } ) ,
174
- ] ,
175
- } ;
176
- buildFormats . push ( postCssConfig ) ;
177
- }
178
-
179
173
// Export config
180
- export default ( commandLineArgs ) => {
181
- // Exporting a method enables command line args override
182
- // https://rollupjs.org/guide/en/#configuration-files
183
- delete commandLineArgs . format ;
184
- return buildFormats ;
185
- } ;
174
+ export default buildFormats ;
0 commit comments