@@ -53,28 +53,20 @@ module.exports = function (content) {
5353 const isProduction = this . minimize || process . env . NODE_ENV === 'production'
5454
5555 const loaderContext = this
56- const query = loaderUtils . getOptions ( this ) || { }
57- const options = Object . assign (
58- {
59- esModule : true
60- } ,
61- this . options . vue ,
62- this . vue ,
63- query
64- )
56+ const options = Object . assign ( { esModule : true } , loaderUtils . getOptions ( this ) )
6557
6658 // shadow mode is an internal option
6759 // enabled via vue-cli's --target web-component
6860 const isShadowMode = ! ! options . shadowMode
6961
7062 // disable esModule in inject mode
7163 // because import/export must be top-level
72- if ( query . inject ) {
64+ if ( options . inject ) {
7365 options . esModule = false
7466 }
7567
76- // #824 avoid multiple webpack runs complaining about unknown option
77- Object . defineProperty ( this . options , '__vueOptions__' , {
68+ // share options between the main loader of style/template loaders
69+ Object . defineProperty ( this . _compilation , '__vueOptions__' , {
7870 value : options ,
7971 enumerable : false ,
8072 configurable : true
@@ -85,8 +77,8 @@ module.exports = function (content) {
8577 const fileName = path . basename ( filePath )
8678
8779 const context =
88- ( this . _compiler && this . _compiler . context ) ||
89- this . options . context ||
80+ this . rootContext ||
81+ ( this . options && this . options . context ) ||
9082 process . cwd ( )
9183 const sourceRoot = path . dirname ( path . relative ( context , filePath ) )
9284 const shortFilePath = path . relative ( context , filePath ) . replace ( / ^ ( \. \. [ \\ \/ ] ) + / , '' )
@@ -135,14 +127,7 @@ module.exports = function (content) {
135127 id : moduleId ,
136128 hasScoped,
137129 hasComment,
138- transformToRequire : options . transformToRequire ,
139- preserveWhitespace : options . preserveWhitespace ,
140- buble : bubleTemplateOptions ,
141- // only pass compilerModules if it's a path string
142- compilerModules :
143- typeof options . compilerModules === 'string'
144- ? options . compilerModules
145- : undefined
130+ buble : bubleTemplateOptions
146131 } )
147132
148133 const defaultLoaders = {
@@ -300,7 +285,7 @@ module.exports = function (content) {
300285 '\n'
301286 }
302287 // inject loader interop
303- if ( query . inject ) {
288+ if ( options . inject ) {
304289 output += '__vue_script__ = __vue_script__(injections)\n'
305290 }
306291 } else {
@@ -423,7 +408,7 @@ module.exports = function (content) {
423408 output += '\n'
424409 }
425410
426- if ( ! query . inject ) {
411+ if ( ! options . inject ) {
427412 // hot reload
428413 if ( needsHotReload ) {
429414 output +=
@@ -615,7 +600,7 @@ module.exports = function (content) {
615600 vue : true ,
616601 id : moduleId ,
617602 scoped : ! ! scoped ,
618- hasInlineConfig : ! ! query . postcss
603+ sourceMap : cssSourceMap
619604 } ) +
620605 '!'
621606 // normalize scss/sass/postcss if no specific loaders have been provided
@@ -636,7 +621,7 @@ module.exports = function (content) {
636621 : loaders [ lang ]
637622
638623 const injectString =
639- type === 'script' && query . inject ? 'inject-loader!' : ''
624+ type === 'script' && options . inject ? 'inject-loader!' : ''
640625
641626 if ( loader != null ) {
642627 if ( Array . isArray ( loader ) ) {
0 commit comments