Skip to content

Commit

Permalink
feat(taro): 调整小程序和 H5 的编译配置
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 31, 2019
1 parent 9f19372 commit 0b47af5
Show file tree
Hide file tree
Showing 32 changed files with 3,617 additions and 4,101 deletions.
6 changes: 3 additions & 3 deletions packages/taro-cli/src/build.ts
Expand Up @@ -3,9 +3,10 @@ import * as fs from 'fs-extra'
import { SyncHook, Hook } from 'tapable'
import * as _ from 'lodash'
import chalk from 'chalk'
import { IProjectConfig, ICommonPlugin } from '@tarojs/taro/types/compile'

import { BUILD_TYPES, PROJECT_CONFIG } from './util/constants'
import { IBuildOptions, IProjectConfig, ICommonPlugin } from './util/types'
import { IBuildOptions } from './util/types'
import { emptyDirectory } from './util'
import CONFIG from './config'

Expand Down Expand Up @@ -38,8 +39,7 @@ export default class Builder {
}

applyPlugins () {
const commonConfig = Object.assign({}, { plugins: [] }, this.config.common)
const plugins = commonConfig.plugins
const plugins = this.config.plugins || []
if (plugins.length) {
plugins.forEach((plugin: ICommonPlugin) => {
plugin.apply(this)
Expand Down
11 changes: 8 additions & 3 deletions packages/taro-cli/src/h5/index.ts
@@ -1,4 +1,5 @@
import { PageConfig } from '@tarojs/taro'
import { IProjectConfig, IH5Config, IH5RouterConfig, IDeviceRatio } from '@tarojs/taro/types/compile'
import wxTransformer from '@tarojs/transformer-wx'
import * as babel from 'babel-core'
import traverse, { NodePath, TraverseOptions } from 'babel-traverse'
Expand Down Expand Up @@ -31,7 +32,7 @@ import {
} from '../util/astConvert'
import { BUILD_TYPES, processTypeEnum, PROJECT_CONFIG, REG_SCRIPTS, REG_TYPESCRIPT } from '../util/constants'
import * as npmProcess from '../util/npm'
import { IBuildConfig, IDeviceRatio, IH5Config, IH5RouterConfig, IOption, IProjectConfig } from '../util/types'
import { IBuildOptions, IOption } from '../util/types'
import {
APIS_NEED_TO_APPEND_THIS,
deviceRatioConfigName,
Expand Down Expand Up @@ -189,7 +190,7 @@ class Compiler {
return Promise.all(readPromises)
}

async buildDist ({ watch, port }: IBuildConfig) {
async buildDist ({ watch, port }: IBuildOptions) {
const isMultiRouterMode = get(this.h5Config, 'router.mode') === 'multi'
const entryFileName = this.entryFileName
const projectConfig = this.projectConfig
Expand Down Expand Up @@ -233,6 +234,10 @@ class Compiler {
},
isWatch: !!watch,
outputRoot: outputDir,
babel: projectConfig.babel,
csso: projectConfig.csso,
uglify: projectConfig.uglify,
sass: projectConfig.sass,
plugins: projectConfig.plugins,
port,
sourceRoot
Expand Down Expand Up @@ -1451,7 +1456,7 @@ class Compiler {

export { Compiler }

export async function build (appPath: string, buildConfig: IBuildConfig) {
export async function build (appPath: string, buildConfig: IBuildOptions) {
process.env.TARO_ENV = BUILD_TYPES.H5
await checkCliAndFrameworkVersion(appPath, BUILD_TYPES.H5)
const compiler = new Compiler(appPath)
Expand Down

0 comments on commit 0b47af5

Please sign in to comment.