@@ -58,7 +58,7 @@ module.exports = function (content) {
58
58
var bubleOptions = hasBuble && options . buble ? '?' + JSON . stringify ( options . buble ) : ''
59
59
var defaultLoaders = {
60
60
html : templateCompilerPath + '?id=' + moduleId ,
61
- css : styleLoaderPath + '!css-loader' + ( needCssSourceMap ? '?sourceMap' : '' ) ,
61
+ css : ( isServer ? '' : styleLoaderPath + '!' ) + ' css-loader' + ( needCssSourceMap ? '?sourceMap' : '' ) ,
62
62
js : hasBuble ? ( 'buble-loader' + bubleOptions ) : hasBabel ? 'babel-loader' : ''
63
63
}
64
64
@@ -177,21 +177,33 @@ module.exports = function (content) {
177
177
var cssModules = { }
178
178
179
179
// add requires for styles
180
- if ( ! isServer && parts . styles . length ) {
180
+ if ( parts . styles . length ) {
181
181
output += '\n/* styles */\n'
182
182
parts . styles . forEach ( function ( style , i ) {
183
183
/* !HACK! */
184
184
style . module = i === 0 ? 'style' : '$style'
185
+
186
+ // require style
187
+ if ( isServer && ! style . module ) return
185
188
var requireString = style . src
186
189
? getRequireForImport ( 'styles' , style , style . scoped )
187
190
: getRequire ( 'styles' , style , i , style . scoped )
191
+
188
192
// setCssModule
189
193
if ( style . module ) {
190
194
if ( style . module in cssModules ) {
191
195
loaderContext . emitError ( 'CSS module name "' + style . module + '" is not unique!' )
192
196
output += requireString
193
197
} else {
194
198
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
+
195
207
output += '__vue_styles__["' + style . module + '"] = ' + requireString + '\n'
196
208
}
197
209
} else {
0 commit comments