Skip to content

Commit

Permalink
fix: join webpackConfig.context to entry path when convert webpack en…
Browse files Browse the repository at this point in the history
…try configuration
  • Loading branch information
Chieffo2021 committed Jul 23, 2021
1 parent abe49e6 commit bfa7ee9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type Entry = string | string[] | { [entryAlias: string]: string } | any;

export interface WebpackConfig extends Config {
mode?: string;
context?: string;
entry?: Entry;
output?: Output;
module?: Module;
Expand Down
19 changes: 16 additions & 3 deletions src/transform/transformWebpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,26 @@ export class WebpackTransformer implements Transformer {
// convert entry
if (webpackConfig.entry !== '' && webpackConfig.entry !== null) {
config.build.rollupOptions = {}
let input
if (isObject(webpackConfig.entry)) {
config.build.rollupOptions.input = suitableFormat(webpackConfig.entry)
input = suitableFormat(webpackConfig.entry)
} else if (typeof webpackConfig.entry === 'function') {
config.build.rollupOptions.input = webpackConfig.entry()
input = webpackConfig.entry()
} else {
config.build.rollupOptions.input = webpackConfig.entry
input = webpackConfig.entry
}
if (input && webpackConfig.context) {
if (isObject(input)) {
Object.keys(input).forEach(key => {
input[key] = path.join(webpackConfig.context, input[key])
})
} else if (Array.isArray(input)) {
input = input.map(item => path.join(webpackConfig.context, item))
} else {
input = path.join(webpackConfig.context, input)
}
}
config.build.rollupOptions.input = input
}
recordConver({ num: 'W01', feat: 'build input options' })
// convert output
Expand Down

0 comments on commit bfa7ee9

Please sign in to comment.