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): @import rule must come first #11246

Merged
merged 11 commits into from
Mar 5, 2022
13 changes: 7 additions & 6 deletions packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1160,19 +1160,20 @@ export default class TaroMiniPlugin {

const originSource: string = assets[appStyle].source()
const source = new ConcatSource()
source.add(originSource)

Object.keys(assets).forEach(assetName => {
const fileName = path.basename(assetName, path.extname(assetName))
if ((REG_STYLE.test(assetName) || REG_STYLE_EXT.test(assetName)) && this.options.commonChunks.includes(fileName)) {
source.add('\n')
source.add(`@import ${JSON.stringify(urlToRequest(assetName))};`)
assets[appStyle] = {
size: () => source.source().length,
source: () => source.source()
}
source.add('\n')
}
})

source.add(originSource)
noyobo marked this conversation as resolved.
Show resolved Hide resolved
assets[appStyle] = {
size: () => source.source().length,
source: () => source.source()
}
}

addTarBarFilesToDependencies (compilation: webpack.compilation.Compilation) {
Expand Down