Skip to content

Commit cf8f6bd

Browse files
JounQinyyx990803
authored andcommitted
Allow manual injection with manualInject option (#13)
* judge `isVue` from loader options alose * generate id via request + resourcePath * fix issue about null options * Update index.js * Update index.js
1 parent 5281305 commit cf8f6bd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ module.exports.pitch = function (remainingRequest) {
1818
var addStylesServerPath = loaderUtils.stringifyRequest(this, '!' + path.join(__dirname, 'lib/addStylesServer.js'))
1919

2020
var request = loaderUtils.stringifyRequest(this, '!!' + remainingRequest)
21-
var id = JSON.stringify(hash(request))
21+
var id = JSON.stringify(hash(request + this.resourcePath))
22+
var options = loaderUtils.getOptions(this) || {}
2223

23-
// direct css import from js --> direct (how does this work when inside an async chunk? ...just don't do it)
24+
// direct css import from js --> direct, or manually call `styles.__inject__(ssrContext)` with `manualInject` option
2425
// css import from vue file --> component lifecycle linked
2526
// style embedded in vue file --> component lifecycle linked
26-
var isVue = /"vue":true/.test(remainingRequest)
27+
var isVue = /"vue":true/.test(remainingRequest) || options.manualInject
2728

2829
var shared = [
2930
'// style-loader: Adds some css to the DOM by adding a <style> tag',

0 commit comments

Comments
 (0)