Skip to content

Commit

Permalink
fix(mini-runner): 暴露 commonChunks 配置以供自定义公共 chunks 生成
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Jan 7, 2020
1 parent cd0f55a commit 8f6bdee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/taro-mini-runner/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ export interface IBuildConfig extends IProjectBaseConfig, IMiniAppConfig {
buildAdapter: BUILD_TYPES,
nodeModulesPath: string,
quickappJSON: any,
isBuildPlugin: boolean
isBuildPlugin: boolean,
commonChunks: string[]
}
7 changes: 5 additions & 2 deletions packages/taro-mini-runner/src/webpack/build.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default (appPath: string, mode, config: Partial<IBuildConfig>): any => {

babel,
csso,
uglify
uglify,
commonChunks
} = config

let { copy } = config
Expand Down Expand Up @@ -83,6 +84,8 @@ export default (appPath: string, mode, config: Partial<IBuildConfig>): any => {
isBuildPlugin: config.isBuildPlugin
})
plugin.definePlugin = getDefinePlugin([constantsReplaceList])
console.log(commonChunks)
const customCommonChunks = commonChunks && commonChunks.length ? commonChunks : !!config.isBuildPlugin ? ['plugin/runtime', 'plugin/vendors'] : ['runtime', 'vendors']
plugin.miniPlugin = getMiniPlugin({
sourceDir,
outputDir,
Expand All @@ -93,7 +96,7 @@ export default (appPath: string, mode, config: Partial<IBuildConfig>): any => {
designWidth,
pluginConfig: entryRes!.pluginConfig,
isBuildPlugin: !!config.isBuildPlugin,
commonChunks: !!config.isBuildPlugin ? ['plugin/runtime', 'plugin/vendors'] : ['runtime', 'vendors'],
commonChunks: customCommonChunks,
alias
})

Expand Down
3 changes: 2 additions & 1 deletion packages/taro/types/compile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export interface IMiniAppConfig {
imageUrlLoaderOption: IOption,
miniCssExtractPluginOption: IOption,

customFilesTypes: IMINI_APP_FILE_TYPE
customFilesTypes: IMINI_APP_FILE_TYPE,
commonChunks: string[]
}

export type TogglableOptions<T = IOption> = {
Expand Down

0 comments on commit 8f6bdee

Please sign in to comment.