Skip to content

Commit c2e3e19

Browse files
committed
fix: filter out empty styles before generating code
1 parent 6c13a34 commit c2e3e19

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/codegen/styleInjection.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { attrsToQuery } = require('./utils')
22
const hotReloadAPIPath = JSON.stringify(require.resolve('vue-hot-reload-api'))
3+
const allWhitespaceRE = /^\s+$/
34

45
module.exports = function genStyleInjectionCode (
56
loaderContext,
@@ -69,6 +70,8 @@ module.exports = function genStyleInjectionCode (
6970
}
7071
}
7172

73+
// filter out empty styles (with no `src` specified or only contains whitespaces)
74+
styles = styles.filter(style => style.src || !allWhitespaceRE.test(style.content))
7275
// explicit injection is needed in SSR (for critical CSS collection)
7376
// or in Shadow Mode (for injection into shadow root)
7477
// In these modes, vue-style-loader exports objects with the __inject__

0 commit comments

Comments
 (0)