@@ -10,49 +10,62 @@ import ce from 'rollup-plugin-condition-exports'
10
10
import esbuild from 'rollup-plugin-esbuild'
11
11
import { externals } from 'rollup-plugin-node-externals'
12
12
import size from 'rollup-plugin-size'
13
+ import { createRequire } from 'node:module'
14
+
15
+ const require = createRequire ( import . meta. url )
16
+
17
+ const plugins = [
18
+ externals ( {
19
+ devDeps : false ,
20
+ builtinsPrefix : 'add' ,
21
+ } ) ,
22
+ commonjs ( ) ,
23
+ replace ( {
24
+ delimiters : [ '' , '' ] ,
25
+ preventAssignment : true ,
26
+ values : {
27
+ 'import \'source-map-support/register.js\';' : '' ,
28
+ } ,
29
+ } ) ,
30
+ esbuild ( {
31
+ minify : false ,
32
+ sourceMap : process . env . BUILD !== 'production' ,
33
+ target : 'es2021' ,
34
+ } ) ,
35
+ alias ( {
36
+ customResolver : resolve ( { extensions : [ '.tsx' , '.ts' ] } ) ,
37
+ entries : Object . entries ( {
38
+ '@/*' : [ './src/*' ] ,
39
+ } ) . map ( ( [ alias , value ] ) => ( {
40
+ find : new RegExp ( `${ alias . replace ( '/*' , '' ) } ` ) ,
41
+ replacement : path . resolve ( process . cwd ( ) , `${ value [ 0 ] . replace ( '/*' , '' ) } ` ) ,
42
+ } ) ) ,
43
+ } ) ,
44
+ resolve ( { browser : false , exportConditions : [ 'node' , 'default' ] } ) ,
45
+ json ( ) ,
46
+ size ( ) ,
47
+ ]
13
48
14
49
export default defineConfig ( [
15
- // CommonJS (for Node) and ES module (for bundlers) build.
16
- // (We could have three entries in the configuration array
17
- // instead of two, but it's quicker to generate multiple
18
- // builds from a single configuration where possible, using
19
- // an array for the `output` option, where we can specify
20
- // `file` and `format` for each target)
50
+ {
51
+ input : {
52
+ 'write-yaml-file/index' : require . resolve ( 'write-yaml-file' )
53
+ } ,
54
+ plugins,
55
+ output : [
56
+ {
57
+ entryFileNames : '[name].cjs' ,
58
+ dir : 'vendors' ,
59
+ chunkFileNames : 'chunks/[name].cjs' ,
60
+ format : 'cjs' ,
61
+ } ,
62
+ ] ,
63
+ } ,
21
64
{
22
65
input : 'src/cli.ts' ,
23
66
preserveEntrySignatures : 'strict' ,
24
67
external : [ 'source-map-support/register.js' ] ,
25
- plugins : [
26
- externals ( {
27
- devDeps : false ,
28
- builtinsPrefix : 'add' ,
29
- } ) ,
30
- commonjs ( ) ,
31
- replace ( {
32
- delimiters : [ '' , '' ] ,
33
- preventAssignment : true ,
34
- values : {
35
- 'import \'source-map-support/register.js\';' : '' ,
36
- } ,
37
- } ) ,
38
- esbuild ( {
39
- minify : false ,
40
- sourceMap : process . env . BUILD !== 'production' ,
41
- target : 'es2021' ,
42
- } ) ,
43
- alias ( {
44
- customResolver : resolve ( { extensions : [ '.tsx' , '.ts' ] } ) ,
45
- entries : Object . entries ( {
46
- '@/*' : [ './src/*' ] ,
47
- } ) . map ( ( [ alias , value ] ) => ( {
48
- find : new RegExp ( `${ alias . replace ( '/*' , '' ) } ` ) ,
49
- replacement : path . resolve ( process . cwd ( ) , `${ value [ 0 ] . replace ( '/*' , '' ) } ` ) ,
50
- } ) ) ,
51
- } ) ,
52
- resolve ( { browser : false , exportConditions : [ 'node' , 'default' ] } ) ,
53
- json ( ) ,
54
- size ( ) ,
55
- ] ,
68
+ plugins,
56
69
watch : {
57
70
exclude : [ './package.json' ] ,
58
71
} ,
@@ -68,32 +81,11 @@ export default defineConfig([
68
81
} ,
69
82
{
70
83
plugins : [
71
- externals ( {
72
- devDeps : false ,
73
- builtinsPrefix : 'add' ,
74
- } ) ,
75
- commonjs ( ) ,
76
- esbuild ( {
77
- minify : false ,
78
- sourceMap : true ,
79
- target : 'es2021' ,
80
- } ) ,
81
- alias ( {
82
- customResolver : resolve ( { extensions : [ '.tsx' , '.ts' ] } ) ,
83
- entries : Object . entries ( {
84
- '@/*' : [ './src/*' ] ,
85
- } ) . map ( ( [ alias , value ] ) => ( {
86
- find : new RegExp ( `${ alias . replace ( '/*' , '' ) } ` ) ,
87
- replacement : path . resolve ( process . cwd ( ) , `${ value [ 0 ] . replace ( '/*' , '' ) } ` ) ,
88
- } ) ) ,
89
- } ) ,
90
- resolve ( { browser : false , exportConditions : [ 'node' , 'default' ] } ) ,
91
- json ( ) ,
92
84
ce ( {
93
85
outDir : 'dist' ,
94
86
declarationDir : 'dts' ,
95
87
} ) ,
96
- size ( ) ,
88
+ ... plugins ,
97
89
] ,
98
90
watch : {
99
91
exclude : [ './package.json' ] ,
0 commit comments