Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webpack-runner): h5环境支持自定义source-map格式 #4722

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/config-detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ Taro app 的入口,同 [webpack.entry](https://webpack.js.org/configuration/en
sourceMap 开关,影响 js、css 的 sourceMap 配置。
dev 状态默认 **开**,prod 状态默认 **关**。

### h5.sourceMapType
sourceMap格式, 默认cheap-module-eval-source-map。[具体配置](https://webpack.js.org/configuration/devtool/#devtool)

### h5.enableDll

dll 开关,开启后将使用 `dllPlugin` 把内置的部分依赖库打包为单独的 dll 文件,
Expand Down
11 changes: 6 additions & 5 deletions packages/taro-webpack-runner/src/config/dev.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
designWidth = 750,
deviceRatio,
enableSourceMap = true,
sourceMapType,
enableExtract = false,

defineConstants = emptyObj,
env = emptyObj,
styleLoaderOption = emptyObj,
Expand All @@ -47,7 +48,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
mediaUrlLoaderOption = emptyObj,
fontUrlLoaderOption = emptyObj,
imageUrlLoaderOption = emptyObj,

miniCssExtractPluginOption = emptyObj,
esnextModules = [],

Expand Down Expand Up @@ -93,7 +94,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 All @@ -106,7 +107,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
deviceRatio,
enableExtract,
enableSourceMap,

styleLoaderOption,
cssLoaderOption,
lessLoaderOption,
Expand All @@ -116,7 +117,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
imageUrlLoaderOption,
mediaUrlLoaderOption,
esnextModules,

module,
plugins,
staticDirectory
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-webpack-runner/src/config/prod.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
designWidth = 750,
deviceRatio,
enableSourceMap = false,
sourceMapType,
enableExtract = true,

defineConstants = emptyObj,
Expand Down Expand Up @@ -114,7 +115,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 All @@ -127,7 +128,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
deviceRatio,
enableExtract,
enableSourceMap,

styleLoaderOption,
cssLoaderOption,
lessLoaderOption,
Expand All @@ -137,7 +138,7 @@ export default function (appPath: string, config: Partial<BuildConfig>): any {
imageUrlLoaderOption,
mediaUrlLoaderOption,
esnextModules,

module,
plugins,
staticDirectory
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 @@ -472,8 +472,8 @@ const getOutput = (appPath: string, [{ outputRoot, publicPath, chunkDirectory },
}
}

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

export {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-webpack-runner/src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface TaroH5Config {
router?: IH5RouterConfig;
devServer: webpackDevServer.Configuration;
enableSourceMap: boolean;
sourceMapType?: 'none' | 'eval' | 'cheap-eval-source-map' | 'cheap-module-eval-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'source-map' | 'inline-source-map' | 'hidden-source-map' | 'nosources-source-map';
enableExtract: boolean;

cssLoaderOption: Option;
Expand Down