fix($core): Index.styl is not injected at the end of the style bundle (close: #1523)

BTW, A theme cannot require the theme's styles at the layout but need use `Index.styl`  instead.
This commit is contained in:
ULIVZ
2019-04-07 00:45:06 +08:00
parent 5876001e02
commit dabf506022
5 changed files with 20 additions and 7 deletions
@@ -31,15 +31,22 @@ module.exports = (options, ctx) => ({
? `@import(${JSON.stringify(userPalette.replace(/[\\]+/g, '/'))})`
: ''
const nullComment = '// null'
// user's palette can override theme's palette.
let paletteContent = themePaletteContent + userPaletteContent
let paletteContent = '// Theme\'s Palette\n'
+ (themePaletteContent || nullComment)
+ '\n\n// User\'s Palette\n'
+ (userPaletteContent || nullComment)
if (ctx.themeAPI.existsParentTheme) {
const parentThemePalette = path.resolve(ctx.themeAPI.parentTheme.path, 'styles/palette.styl')
const parentThemePaletteContent = fs.existsSync(parentThemePalette)
? `@import(${JSON.stringify(parentThemePalette.replace(/[\\]+/g, '/'))})`
: ''
paletteContent = parentThemePaletteContent + paletteContent
paletteContent = '// Parent Theme\'s Palette\n'
+ (parentThemePaletteContent || nullComment)
+ '\n\n' + paletteContent
}
await writeTemp('palette.styl', paletteContent)
@@ -30,14 +30,23 @@ module.exports = (options, ctx) => ({
? `@import(${JSON.stringify(userStyle.replace(/[\\]+/g, '/'))})`
: ''
let styleContent = themeStyleContent + userStyleContent
const nullComment = '// null'
// user's styles can override theme's styles.
let styleContent = '// Theme\'s Styles\n'
+ (themeStyleContent || nullComment)
+ '\n\n// User\'s Styles\n'
+ (userStyleContent || nullComment)
if (themeAPI.existsParentTheme) {
const parentThemeStyle = path.resolve(themeAPI.parentTheme.path, 'styles/index.styl')
const parentThemeStyleContent = fs.existsSync(parentThemeStyle)
? `@import(${JSON.stringify(parentThemeStyle.replace(/[\\]+/g, '/'))})`
: ''
styleContent = parentThemeStyleContent + styleContent
styleContent = '// Parent Theme\'s Styles\n'
+ (parentThemeStyleContent || nullComment)
+ '\n\n' + styleContent
}
await writeTemp('style.styl', styleContent)
@@ -24,5 +24,3 @@ export default {
}
}
</script>
<style src="../styles/theme.styl" lang="stylus"></style>
@@ -147,4 +147,3 @@ export default {
</script>
<style src="prismjs/themes/prism-tomorrow.css"></style>
<style src="../styles/theme.styl" lang="stylus"></style>