@@ -15,7 +15,6 @@ module.exports.pitch = function (remainingRequest) {
15
15
var isProduction = this . minimize || process . env . NODE_ENV === 'production'
16
16
var addStylesClientPath = loaderUtils . stringifyRequest ( this , '!' + path . join ( __dirname , 'lib/addStylesClient.js' ) )
17
17
var addStylesServerPath = loaderUtils . stringifyRequest ( this , '!' + path . join ( __dirname , 'lib/addStylesServer.js' ) )
18
- var addStylesShadowPath = loaderUtils . stringifyRequest ( this , '!' + path . join ( __dirname , 'lib/addStylesShadow.js' ) )
19
18
20
19
var request = loaderUtils . stringifyRequest ( this , '!!' + remainingRequest )
21
20
var relPath = path . relative ( __dirname , this . resourcePath ) . replace ( / \\ / g, '/' )
@@ -41,41 +40,41 @@ module.exports.pitch = function (remainingRequest) {
41
40
'if(content.locals) module.exports = content.locals;'
42
41
]
43
42
44
- // shadowMode is enabled in vue-cli with vue build --target web-component.
45
- // exposes the same __inject__ method like SSR
46
- if ( options . shadowMode ) {
47
- return shared . concat ( [
48
- '// add CSS to Shadow Root' ,
49
- 'var add = require(' + addStylesShadowPath + ').default' ,
50
- 'module.exports.__inject__ = function (shadowRoot) {' ,
51
- ' add(' + id + ', content, shadowRoot)' ,
52
- '};'
53
- ] ) . join ( '\n' )
54
- } else if ( ! isServer ) {
55
- // on the client: dynamic inject + hot-reload
56
- var code = [
57
- '// add the styles to the DOM' ,
58
- 'var add = require(' + addStylesClientPath + ').default' ,
59
- 'var update = add(' + id + ', content, ' + isProduction + ', ' + JSON . stringify ( options ) + ');'
60
- ]
61
- if ( ! isProduction ) {
62
- code = code . concat ( [
63
- '// Hot Module Replacement' ,
64
- 'if(module.hot) {' ,
65
- ' // When the styles change, update the <style> tags' ,
66
- ' if(!content.locals) {' ,
67
- ' module.hot.accept(' + request + ', function() {' ,
68
- ' var newContent = require(' + request + ');' ,
69
- " if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];" ,
70
- ' update(newContent);' ,
71
- ' });' ,
72
- ' }' ,
73
- ' // When the module is disposed, remove the <style> tags' ,
74
- ' module.hot.dispose(function() { update(); });' ,
75
- '}'
76
- ] )
43
+ if ( ! isServer ) {
44
+ var code = function ( id , isProduction , options ) {
45
+ // style-loader: Adds some css to the DOM by adding a <style> tag
46
+ var content = require ( REQUEST )
47
+ var addStylesClient = require ( ADD_STYLES_CLIENT_PATH ) . default
48
+ var install = function ( target ) {
49
+ update = addStylesClient ( id , content , isProduction , options , target )
50
+ }
51
+ var update = null
52
+ if ( typeof content === 'string' ) content = [ [ module . id , content , '' ] ]
53
+ if ( content . locals ) {
54
+ module . exports = content . locals
55
+ return
56
+ } else if ( module . hot ) {
57
+ module . hot . accept ( REQUEST , function ( ) {
58
+ var newContent = require ( REQUEST )
59
+ if ( typeof newContent === 'string' ) newContent = [ [ module . id , newContent , '' ] ]
60
+ update ( newContent )
61
+ } )
62
+ module . hot . dispose ( function ( ) {
63
+ update ( ) ;
64
+ } )
65
+ }
66
+ if ( options . shadowMode ) {
67
+ module . exports . __inject__ = function ( shadowRoot ) {
68
+ install ( shadowRoot )
69
+ }
70
+ } else {
71
+ install ( typeof document !== 'undefined' && document . head )
72
+ }
77
73
}
78
- return shared . concat ( code ) . join ( '\n' )
74
+ return `(${ code } )(${ id } ,${ isProduction } ,${ JSON . stringify ( options ) } )`
75
+ . split ( 'REQUEST' ) . join ( request )
76
+ . split ( 'ADD_STYLES_CLIENT_PATH' ) . join ( addStylesClientPath )
77
+
79
78
} else {
80
79
// on the server: attach to Vue SSR context
81
80
if ( isVue ) {
0 commit comments