Skip to content

Commit

Permalink
refactor(webpack-runner): 同步 2.x 的 sourceMapType 配置项 (#6544)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj authored Jun 16, 2020
1 parent 9a2c419 commit 04b0962
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "node",
"request": "launch",
"name": "CLI debug",
"program": "${workspaceFolder}/packages/taro-cli/bin/taro-build",
"program": "${workspaceFolder}/packages/taro-cli/bin/taro",
// "cwd": "${project absolute path}",
// "args": [
// "build",
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-webpack-runner/src/config/dev.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
designWidth = 750,
deviceRatio,
enableSourceMap = true,
sourceMapType,
enableExtract = false,

defineConstants = emptyObj,
Expand Down Expand Up @@ -113,7 +114,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {

chain.merge({
mode,
devtool: getDevtool([enableSourceMap]),
devtool: getDevtool({ enableSourceMap, sourceMapType }),
entry,
output: getOutput(appPath, [{
outputRoot,
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-webpack-runner/src/config/prod.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
designWidth = 750,
deviceRatio,
enableSourceMap = false,
sourceMapType,
enableExtract = true,

defineConstants = emptyObj,
Expand Down Expand Up @@ -132,7 +133,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {

chain.merge({
mode,
devtool: getDevtool(enableSourceMap),
devtool: getDevtool({ enableSourceMap, sourceMapType }),
entry,
output: getOutput(appPath, [{
outputRoot,
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-webpack-runner/src/util/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,6 @@ export const getOutput = (appPath: string, [{ outputRoot, publicPath, chunkDirec
}
}

export const getDevtool = enableSourceMap => {
return enableSourceMap ? 'cheap-module-eval-source-map' : 'none'
export const getDevtool = ({ enableSourceMap, sourceMapType = 'cheap-module-eval-source-map' }) => {
return enableSourceMap ? sourceMapType : 'none'
}

0 comments on commit 04b0962

Please sign in to comment.