Skip to content

Commit

Permalink
fix(cli): 修复部分文件打包时不压缩的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed May 23, 2019
1 parent def3cab commit 4699d02
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions packages/taro-cli/src/mini/astProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import {
isAliasPath,
replaceAliasPath,
traverseObjectNode,
isQuickAppPkg
isQuickAppPkg,
getBabelConfig
} from '../util'
import {
convertObjectToAstExpression,
Expand Down Expand Up @@ -476,8 +477,8 @@ export function parseAst (
npmOutputDir,
compileInclude,
env: projectConfig.env || {},
uglify: projectConfig!.plugins!.uglify || {},
babelConfig: projectConfig!.plugins!.babel || {}
uglify: projectConfig!.plugins!.uglify || { enable: true },
babelConfig: getBabelConfig(projectConfig!.plugins!.babel) || {}
})
} else {
source.value = value
Expand Down Expand Up @@ -582,8 +583,8 @@ export function parseAst (
npmOutputDir,
compileInclude,
env: projectConfig.env || {},
uglify: projectConfig!.plugins!.uglify || {},
babelConfig: projectConfig!.plugins!.babel || {}
uglify: projectConfig!.plugins!.uglify || { enable: true },
babelConfig: getBabelConfig(projectConfig!.plugins!.babel) || {}
})
} else {
args[0].value = value
Expand Down Expand Up @@ -869,8 +870,8 @@ export function parseAst (
npmOutputDir,
compileInclude,
env: projectConfig.env || {},
uglify: projectConfig!.plugins!.uglify || {},
babelConfig: projectConfig!.plugins!.babel || {}
uglify: projectConfig!.plugins!.uglify || { enable: true },
babelConfig: getBabelConfig(projectConfig!.plugins!.babel) || {}
}) : taroMiniAppFramework
switch (type) {
case PARSE_AST_TYPE.ENTRY:
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli/src/mini/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function compileDepScripts (scriptFiles: string[], needUseBabel?: boolean
}
fs.ensureDirSync(path.dirname(outputItem))
if (isProduction && needUseBabel) {
uglifyJS(resCode, item, appPath, projectConfig!.plugins!.uglify as TogglableOptions)
resCode = uglifyJS(resCode, item, appPath, projectConfig!.plugins!.uglify as TogglableOptions)
}
if (NODE_MODULES_REG.test(item)) {
resCode = npmCodeHack(outputItem, resCode, buildAdapter)
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-cli/src/mini/compileStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
import {
isNpmPkg,
processStyleImports,
promoteRelativePath
promoteRelativePath,
getBabelConfig
} from '../util'
import { CSS_EXT, FILE_PROCESSOR_MAP, DEVICE_RATIO_NAME, BUILD_TYPES } from '../util/constants'
import { IMiniAppConfig } from '../util/types'
Expand Down Expand Up @@ -222,8 +223,8 @@ export function compileDepStyles (outputFilePath: string, styleFiles: string[])
npmOutputDir,
compileInclude,
env: projectConfig.env || {},
uglify: projectConfig!.plugins!.uglify || {},
babelConfig: projectConfig!.plugins!.babel || {}
uglify: projectConfig!.plugins!.uglify || { enable: true },
babelConfig: getBabelConfig(projectConfig!.plugins!.babel) || {}
})
const importRelativePath = promoteRelativePath(path.relative(filePath, npmInfo.main))
return str.replace(stylePath, importRelativePath)
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli/src/mini/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export async function buildSingleComponent (
if (!isQuickApp) {
resCode = await compileScriptFile(resCode, component, outputComponentJSPath, buildAdapter)
if (isProduction) {
uglifyJS(resCode, component, appPath, projectConfig!.plugins!.uglify as TogglableOptions)
resCode = uglifyJS(resCode, component, appPath, projectConfig!.plugins!.uglify as TogglableOptions)
}
} else {
// 快应用编译,搜集创建组件 ux 文件
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli/src/mini/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export async function buildSinglePage (page: string) {
if (!isQuickApp) {
resCode = await compileScriptFile(resCode, pageJs, outputPageJSPath, buildAdapter)
if (isProduction) {
uglifyJS(resCode, pageJs, appPath, projectConfig!.plugins!.uglify as TogglableOptions)
resCode = uglifyJS(resCode, pageJs, appPath, projectConfig!.plugins!.uglify as TogglableOptions)
}
} else {
// 快应用编译,搜集创建页面 ux 文件
Expand Down

0 comments on commit 4699d02

Please sign in to comment.