Skip to content

Commit

Permalink
fix(taro): 将 file-loader 的 esModule 参数默认设置为 false,以支持 commonjs 的方式引用资源,
Browse files Browse the repository at this point in the history
…close #7869
  • Loading branch information
luckyadam authored and Chen-jj committed Oct 21, 2020
1 parent 64361e4 commit 0ded20d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/taro-loader/src/h5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ var tabbarSelectedIconPath = []
for (let i = 0; i < tabbarList.length; i++) {
const t = tabbarList[i]
if (t.iconPath) {
tabBarCode += `tabbarIconPath[${i}] = require(${stringify(join(dirname(this.resourcePath), t.iconPath))}).default\n`
const iconPath = stringify(join(dirname(this.resourcePath), t.iconPath))
tabBarCode += `tabbarIconPath[${i}] = typeof require(${iconPath}) === 'object' ? require(${iconPath}).default : require(${iconPath})\n`
}
if (t.selectedIconPath) {
tabBarCode += `tabbarSelectedIconPath[${i}] = require(${stringify(join(dirname(this.resourcePath), t.selectedIconPath))}).default\n`
const iconPath = stringify(join(dirname(this.resourcePath), t.selectedIconPath))
tabBarCode += `tabbarSelectedIconPath[${i}] = typeof require(${iconPath}) === 'object' ? require(${iconPath}).default : require(${iconPath})\n`
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions packages/taro-mini-runner/src/webpack/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ const defaultCSSCompressOption = {
}

const defaultMediaUrlLoaderOption = {
limit: 10240
limit: 10240,
esModule: false
}
const defaultFontUrlLoaderOption = {
limit: 10240
limit: 10240,
esModule: false
}
const defaultImageUrlLoaderOption = {
limit: 2046
limit: 2046,
esModule: false
}
const defaultCssModuleOption: PostcssOption.cssModules = {
enable: false,
Expand Down
9 changes: 6 additions & 3 deletions packages/taro-webpack-runner/src/util/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ const defaultCSSCompressOption = {
minifySelectors: false
}
const defaultMediaUrlLoaderOption = {
limit: 10240
limit: 10240,
esModule: false
}
const defaultFontUrlLoaderOption = {
limit: 10240
limit: 10240,
esModule: false
}
const defaultImageUrlLoaderOption = {
limit: 10240
limit: 10240,
esModule: false
}
const defaultCssModuleOption: PostcssOption.cssModules = {
enable: false,
Expand Down

0 comments on commit 0ded20d

Please sign in to comment.