File tree Expand file tree Collapse file tree 4 files changed +22
-28
lines changed Expand file tree Collapse file tree 4 files changed +22
-28
lines changed Original file line number Diff line number Diff line change @@ -76,11 +76,17 @@ It is possible to configure the build process via a config file or via cli optio
7676``` javascript
7777const { createConfig } = require (' @teclone/rollup-all' );
7878module .exports = createConfig ({
79+ /**
80+ * defines formats to build
81+ */
82+ formats: [' cjs' , ' es' ],
83+
84+ /**
85+ * defines default configurations for all build formats
86+ */
7987 defaults: {
8088 src: ' ./src' ,
8189
82- out: ' ./build' ,
83-
8490 entryFile: ' ./index' ,
8591
8692 /**
@@ -118,25 +124,21 @@ module.exports = createConfig({
118124 * cjs build config
119125 */
120126 cjs: {
121- enabled: true ,
122127 out: ' ./build/cjs' ,
123128 },
124129
125130 /**
126131 * es build config
127132 */
128133 es: {
129- enabled: true ,
130134 out: ' ./build/es' ,
131135 },
132136
133137 /**
134138 * iife build config, disabled by default
135139 */
136140 iife: {
137- enabled: true ,
138141 out: ' ./build/iife' ,
139- src: ' ./src' ,
140142
141143 // defines outputs
142144 outputs: [
@@ -151,10 +153,7 @@ module.exports = createConfig({
151153 * umd build config, disabled by default
152154 */
153155 umd: {
154- enabled: false ,
155156 out: ' ./build/umd' ,
156- src: ' ./src' ,
157-
158157 // defines outputs
159158 outputs: [
160159 [' development' , ' minified' ],
@@ -193,11 +192,11 @@ This configuration is achieved using the output option as shown below
193192``` typescript
194193const { createConfig } = require (' @teclone/rollup-all' );
195194module .exports = createConfig ({
195+ formats: [' umd' ],
196196 /**
197- * umd build config, disabled by default
197+ * umd build config
198198 */
199199 umd: {
200- enabled: false ,
201200 out: ' ./build/umd' ,
202201 src: ' ./src' ,
203202
Original file line number Diff line number Diff line change @@ -9,8 +9,6 @@ export type Sourcemap = true | false | 'inline';
99export interface FormatConfig {
1010 moduleName ?: string ;
1111
12- enabled ?: boolean ;
13-
1412 src ?: string ;
1513
1614 out ?: string ;
@@ -79,14 +77,19 @@ export interface FormatConfig {
7977 minifiedSuffix ?: string | false ;
8078}
8179
82- export type Config = Partial < {
83- [ p in BuildFormat | 'defaults' ] : FormatConfig ;
84- } > & {
80+ export type Config = {
81+ /**
82+ * formats to build
83+ */
84+ formats ?: Array < BuildFormat > ;
85+
8586 /**
8687 * if true, output logs are not logged
8788 */
8889 silent ?: boolean ;
89- } ;
90+ } & Partial < {
91+ [ p in BuildFormat | 'defaults' ] : FormatConfig ;
92+ } > ;
9093
9194export interface Module {
9295 // id for indexing this file
Original file line number Diff line number Diff line change 11import { Config } from './@types' ;
22
33export const config : Config = {
4+ formats : [ 'cjs' , 'es' ] ,
45 defaults : {
56 src : './src' ,
67
7- out : './build' ,
8-
98 entryFile : './index' ,
109
1110 /**
@@ -43,25 +42,21 @@ export const config: Config = {
4342 * cjs build config
4443 */
4544 cjs : {
46- enabled : true ,
4745 out : './build/cjs' ,
4846 } ,
4947
5048 /**
5149 * es build config
5250 */
5351 es : {
54- enabled : true ,
5552 out : './build/es' ,
5653 } ,
5754
5855 /**
5956 * iife build config, disabled by default
6057 */
6158 iife : {
62- enabled : false ,
6359 out : './build/iife' ,
64- src : './src' ,
6560
6661 // defines outputs
6762 outputs : [
@@ -76,7 +71,6 @@ export const config: Config = {
7671 * umd build config, disabled by default
7772 */
7873 umd : {
79- enabled : false ,
8074 out : './build/umd' ,
8175 src : './src' ,
8276
@@ -85,6 +79,7 @@ export const config: Config = {
8579 [ 'development' , 'minified' ] ,
8680 [ 'production' , 'minified' ] ,
8781 ] ,
82+
8883 minifiedSuffix : 'min' ,
8984 } ,
9085} ;
Original file line number Diff line number Diff line change @@ -394,11 +394,8 @@ class Bundler {
394394 async process ( ) {
395395 const config = this . config ;
396396
397- forEach ( formats , async ( format ) => {
397+ forEach ( config . formats , async ( format ) => {
398398 const formatConfig = config [ format ] ;
399- if ( ! formatConfig . enabled ) {
400- return ;
401- }
402399
403400 const modules = await this . getModules (
404401 [ ] ,
You can’t perform that action at this time.
0 commit comments