How to use the vue-template-compiler/build.js.ssrCompile function in vue-template-compiler

To help you get started, we’ve selected a few vue-template-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-component-compiler / src / template-compiler / index.js View on Github external
module.exports = function compileTemplate (template, filename, config) {
  assertType({ filename }, 'string')
  template = Template(template)
  config = Config(config)

  const options = config.options

  options.scopeId = config.scopeId
  options.modules = [].concat(options.modules || [], config.plugins || [], [
    transformRequire(config.transformToRequire),
    transformSrcset
  ])

  const compile =
    config.isServer && config.optimizeSSR !== false && compiler.ssrCompile
      ? compiler.ssrCompile
      : compiler.compile
  const compiled = compile(template.code, options)
  const output = {
    errors: compiled.errors,
    tips: compiled.tips
  }

  if (output.errors && output.errors.length) {
    output.code = `function render () {}\nvar staticRenderFns = []\n`
  } else {
    const stripWithFunctional =
      template.descriptor.attrs && template.descriptor.attrs.functional

    config.buble.transforms.stripWithFunctional = stripWithFunctional

    output.code = transpile(
github vuejs / vue-component-compiler / src / template-compiler / index.js View on Github external
module.exports = function compileTemplate (template, filename, config) {
  assertType({ filename }, 'string')
  template = Template(template)
  config = Config(config)

  const options = config.options

  options.scopeId = config.scopeId
  options.modules = [].concat(options.modules || [], config.plugins || [], [
    transformRequire(config.transformToRequire),
    transformSrcset
  ])

  const compile =
    config.isServer && config.optimizeSSR !== false && compiler.ssrCompile
      ? compiler.ssrCompile
      : compiler.compile
  const compiled = compile(template.code, options)
  const output = {
    errors: compiled.errors,
    tips: compiled.tips
  }

  if (output.errors && output.errors.length) {
    output.code = `function render () {}\nvar staticRenderFns = []\n`
  } else {
    const stripWithFunctional =
      template.descriptor.attrs && template.descriptor.attrs.functional

    config.buble.transforms.stripWithFunctional = stripWithFunctional