@@ -58,7 +58,7 @@ module.exports = function (content) {
5858 var bubleOptions = hasBuble && options . buble ? '?' + JSON . stringify ( options . buble ) : ''
5959 var defaultLoaders = {
6060 html : templateCompilerPath + '?id=' + moduleId ,
61- css : styleLoaderPath + '!css-loader' + ( needCssSourceMap ? '?sourceMap' : '' ) ,
61+ css : ( isServer ? '' : styleLoaderPath + '!' ) + ' css-loader' + ( needCssSourceMap ? '?sourceMap' : '' ) ,
6262 js : hasBuble ? ( 'buble-loader' + bubleOptions ) : hasBabel ? 'babel-loader' : ''
6363 }
6464
@@ -177,21 +177,33 @@ module.exports = function (content) {
177177 var cssModules = { }
178178
179179 // add requires for styles
180- if ( ! isServer && parts . styles . length ) {
180+ if ( parts . styles . length ) {
181181 output += '\n/* styles */\n'
182182 parts . styles . forEach ( function ( style , i ) {
183183 /* !HACK! */
184184 style . module = i === 0 ? 'style' : '$style'
185+
186+ // require style
187+ if ( isServer && ! style . module ) return
185188 var requireString = style . src
186189 ? getRequireForImport ( 'styles' , style , style . scoped )
187190 : getRequire ( 'styles' , style , i , style . scoped )
191+
188192 // setCssModule
189193 if ( style . module ) {
190194 if ( style . module in cssModules ) {
191195 loaderContext . emitError ( 'CSS module name "' + style . module + '" is not unique!' )
192196 output += requireString
193197 } else {
194198 cssModules [ style . module ] = true
199+
200+ // `style-loader` exposes the name-to-hash map directly
201+ // `css-loader` exposes it in `.locals`
202+ // We drop `style-loader` in SSR, and add `.locals` here.
203+ if ( isServer ) {
204+ requireString += '.locals'
205+ }
206+
195207 output += '__vue_styles__["' + style . module + '"] = ' + requireString + '\n'
196208 }
197209 } else {
0 commit comments