Skip to content

Commit

Permalink
feat: supported umd.sourcemap option (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
bloody-ux authored and sorrycc committed Nov 20, 2019
1 parent f55424b commit d01a2e0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ cjs 为 `rollup` 或 `babel` 时,等同于配置了 `{ type: "rollup" | "babel

是否输出 umd 格式,以及指定 umd 的相关配置。

* Type: `{ globals, name, minFile, file } | false`
* Type: `{ globals, name, minFile, file, sourcemap } | false`
* Default: `false`

#### umd.globals
Expand Down Expand Up @@ -264,6 +264,13 @@ cjs 为 `rollup` 或 `babel` 时,等同于配置了 `{ type: "rollup" | "babel
- Type: `string`
- Default: `undefined`

#### umd.sourcemap

是否同步输出sourcemap。

- Type: `boolean`
- Default: `undefined`

#### autoprefixer

配置参数传给 autoprefixer,详见 [autoprefixer#options](https://github.com/postcss/autoprefixer#options),常用的有 `flexbox``browsers`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

export default {
umd: {
minFile: false,
name: 'foo',
sourcemap: true,
},
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export default function () {
return 'foo';
}
2 changes: 2 additions & 0 deletions packages/father-build/src/getRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export default function(opts: IGetRollupConfigOpts): RollupOptions[] {
input,
output: {
format,
sourcemap: umd && umd.sourcemap,
file: join(cwd, `dist/${(umd && umd.file) || `${name}.umd`}.js`),
globals: umd && umd.globals,
name: (umd && umd.name) || (pkg.name && camelCase(basename(pkg.name))),
Expand All @@ -286,6 +287,7 @@ export default function(opts: IGetRollupConfigOpts): RollupOptions[] {
input,
output: {
format,
sourcemap: umd && umd.sourcemap,
file: join(cwd, `dist/${(umd && umd.file) || `${name}.umd`}.min.js`),
globals: umd && umd.globals,
name: (umd && umd.name) || (pkg.name && camelCase(basename(pkg.name))),
Expand Down
2 changes: 1 addition & 1 deletion packages/father-build/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const successValidates = {
file: ['a'],
esm: [false, true, { type: 'rollup' }, { type: 'babel' }, { file: 'a' }, { mjs: true }],
cjs: [false, true, { type: 'rollup' }, { type: 'babel' }, { file: 'a' }],
umd: [{ globals: {} }, { file: 'a' }, { name: 'a' }, { minFile: false }, { minFile: true }],
umd: [{ globals: {} }, { file: 'a' }, { name: 'a' }, { minFile: false }, { minFile: true }, { sourcemap: true }],
extraBabelPlugins: [[]],
extraBabelPresets: [[]],
extraPostCSSPlugins: [[]],
Expand Down
1 change: 1 addition & 0 deletions packages/father-build/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default {
file: noEmptyStr,
name: noEmptyStr,
minFile: { type: 'boolean' },
sourcemap: { type: 'boolean' },
},
},
],
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 @@ -29,6 +29,7 @@ interface IUmd {
name?: string;
minFile?: boolean;
file?: string;
sourcemap?: boolean;
}

export interface IBundleOptions {
Expand Down

0 comments on commit d01a2e0

Please sign in to comment.