Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: inject style for non-modules too
Browse files Browse the repository at this point in the history
  • Loading branch information
znck committed Oct 29, 2017
1 parent 0bee641 commit 9a30f9e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/assemble.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function assemble (source, filename, config) {
shortFilePath: filename,
require: {
vueHotReloadAPI: 'vue-hot-reload-api',
normalizeComponent: 'vue-component-compiler/src/normalize-component.js'
normalizeComponent: 'vue-component-compiler/src/runtime/normalize-component.js'
},
scopeId: null,
moduleIdentifier: config.moduleIdentifier || hash(_s({ filename, config })), // require for server. TODO: verify this is correct.
Expand Down Expand Up @@ -61,14 +61,14 @@ module.exports = function assemble (source, filename, config) {
const IMPORT_NAME = `__vue_style_${i}__`
const IMPORT_STRING = _s(style.id)
const moduleName = (style.descriptor.module === true) ? '$style' : style.descriptor.module
const needsStyleInjection = config.isServer && config.hasStyleInjectFn
const needsStyleInjection = config.hasStyleInjectFn
const needsNamedImport = needsStyleInjection || typeof moduleName === 'string'
const runInjection = needsStyleInjection ? `${IMPORT_NAME} && ${IMPORT_NAME}.__inject__ && ${IMPORT_NAME}.__inject__(ssrContext)\n` : ''

if (needsNamedImport) {
output += config.esModule
? `import ${IMPORT_NAME} from ${IMPORT_STRING}\n`
: `const ${IMPORT_NAME} = requrie(${IMPORT_STRING})\n`
: `const ${IMPORT_NAME} = require(${IMPORT_STRING})\n`
} else {
output += config.esModule
? `import ${IMPORT_STRING}\n`
Expand Down Expand Up @@ -114,6 +114,7 @@ module.exports = function assemble (source, filename, config) {
}
}
} else {
styleInjectionCode += runInjection
}
})
output += `function ${INJECT_STYLE_FN} (ssrContext) {\n` + pad(styleInjectionCode) + `}\n`
Expand Down

0 comments on commit 9a30f9e

Please sign in to comment.