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

fix(mini-runner): 修复 sass 解析 alias 失败,fix #9207 #9211

Merged
merged 2 commits into from
Apr 28, 2021
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
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