Skip to content

Commit

Permalink
fix(mini-runner): 修复 sass 解析 alias 失败,fix #9207 (#9211)
Browse files Browse the repository at this point in the history
* fix(mini-runner): 修复 sass 解析 alias 失败,fix #9207

* fix(webpack-runner): 修复 sass 解析 alias 失败
  • Loading branch information
Chen-jj authored Apr 28, 2021
1 parent 622ca7a commit 51ca357
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions packages/taro-mini-runner/src/webpack/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,21 @@ export const getModule = (appPath: string, {
// 让 sass 文件里的 @import 能解析小程序原生样式文体,如 @import "a.wxss";
const extname = path.extname(url)
if (extname === '.scss' || extname === '.sass' || extname === '.css') {
done({
file: url
})
return null
} else {
const filePath = path.resolve(path.dirname(prev), url)
fs.access(filePath, fs.constants.F_OK, (err) => {
if (err) {
console.log(err)
done({ file: url })
return null
} else {
fs.readFile(filePath)
.then(res => {
done({ contents: res.toString() })
})
.catch(err => {
console.log(err)
done({ file: url })
return null
})
}
})
Expand Down
8 changes: 3 additions & 5 deletions packages/taro-webpack-runner/src/util/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,23 +416,21 @@ export const getModule = (appPath: string, {
// 让 sass 文件里的 @import 能解析小程序原生样式文体,如 @import "a.wxss";
const extname = path.extname(url)
if (extname === '.scss' || extname === '.sass' || extname === '.css') {
done({
file: url
})
return null
} else {
const filePath = path.resolve(path.dirname(prev), url)
fs.access(filePath, fs.constants.F_OK, (err) => {
if (err) {
console.log(err)
done({ file: url })
return null
} else {
fs.readFile(filePath)
.then(res => {
done({ contents: res.toString() })
})
.catch(err => {
console.log(err)
done({ file: url })
return null
})
}
})
Expand Down

0 comments on commit 51ca357

Please sign in to comment.