Skip to content

Commit

Permalink
feat: support extraRollupPlugins (umijs#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc authored Sep 24, 2019
1 parent 6aa012c commit bb6c962
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,21 @@ export default {
* Type: `array`
* Default: `[]`

#### extraRollupPlugins

配置额外的 rollup plugin。

* Type: `array`
* Default: `[]`

```js
import url from 'rollup-plugin-url';

export default {
extraRollupPlugins:[url()],
};
```

#### extraExternals

为 rollup 模式配置额外的 external,但不推荐这么做,external 可通过 dependencies 和 peerDependencies 的约定实现。
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import replace from 'rollup-plugin-replace';

export default {
esm: { type: 'rollup' },
extraRollupPlugins: [
replace({
VERSION: JSON.stringify('1.0.0'),
}),
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("1.0.0");
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "0.1.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

console.log(VERSION);
2 changes: 2 additions & 0 deletions packages/father-build/src/getRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function(opts: IGetRollupConfigOpts): RollupOptions[] {
extraPostCSSPlugins = [],
extraBabelPresets = [],
extraBabelPlugins = [],
extraRollupPlugins = [],
autoprefixer: autoprefixerOpts,
include = /node_modules/,
namedExports,
Expand Down Expand Up @@ -184,6 +185,7 @@ export default function(opts: IGetRollupConfigOpts): RollupOptions[] {
: []),
babel(babelOpts),
json(),
...(extraRollupPlugins || []),
];

switch (type) {
Expand Down
3 changes: 3 additions & 0 deletions packages/father-build/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export default {
extraPostCSSPlugins: {
type: 'array',
},
extraRollupPlugins: {
type: 'array',
},
extraExternals: {
type: 'array',
},
Expand Down
1 change: 1 addition & 0 deletions packages/father-build/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface IBundleOptions {
extraBabelPlugins?: any[];
extraBabelPresets?: any[];
extraPostCSSPlugins?: any[];
extraRollupPlugins?: any[];
extraExternals?: string[];
externalsExclude?: string[];
cssModules?: boolean | Object;
Expand Down

0 comments on commit bb6c962

Please sign in to comment.