{"action":"closed","issue":{"url":"https://api.github.com/repos/vuejs/vue-cli/issues/1398","repository_url":"https://api.github.com/repos/vuejs/vue-cli","labels_url":"https://api.github.com/repos/vuejs/vue-cli/issues/1398/labels{/name}","comments_url":"https://api.github.com/repos/vuejs/vue-cli/issues/1398/comments","events_url":"https://api.github.com/repos/vuejs/vue-cli/issues/1398/events","html_url":"https://github.com/vuejs/vue-cli/issues/1398","id":327465821,"number":1398,"title":"How to add ssr to a vue-cli 3 project?","user":{"login":"leonardovilarinho","id":12480135,"avatar_url":"https://avatars2.githubusercontent.com/u/12480135?v=4","gravatar_id":"","url":"https://api.github.com/users/leonardovilarinho","html_url":"https://github.com/leonardovilarinho","followers_url":"https://api.github.com/users/leonardovilarinho/followers","following_url":"https://api.github.com/users/leonardovilarinho/following{/other_user}","gists_url":"https://api.github.com/users/leonardovilarinho/gists{/gist_id}","starred_url":"https://api.github.com/users/leonardovilarinho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonardovilarinho/subscriptions","organizations_url":"https://api.github.com/users/leonardovilarinho/orgs","repos_url":"https://api.github.com/users/leonardovilarinho/repos","events_url":"https://api.github.com/users/leonardovilarinho/events{/privacy}","received_events_url":"https://api.github.com/users/leonardovilarinho/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-29T19:59:54Z","updated_at":"2018-05-29T19:59:55Z","closed_at":"2018-05-29T19:59:55Z","author_association":"NONE","body":"In all SSR tutorials with Vue that I found the webpack merge is used to create a configuration for the server. Could you explain quickly how I would do this in the design created by vue-cli 3? I am also using the PWA plugin.\r\n\r\n\r\nMy current code is:\r\n\r\nfactory.js\r\n```javascript\r\n...\r\nexport default () => new Vue({\r\n  router,\r\n  store,\r\n  render: h => h(App)\r\n})\r\n```\r\n\r\nserver.js\r\n```javascript\r\nconst express = require('express')\r\nconst { resolve } = require('path')\r\nconst fs = require('fs')\r\n\r\nglobal.Vue = require('vue')\r\nconst layout = fs.readFileSync(resolve(__dirname, './dist/index.html'), 'utf8')\r\nconst renderer = require('vue-server-renderer').createRenderer()\r\n\r\nconst app = express()\r\napp.use('/dist', express.static(\r\n  resolve(__dirname, './dist')\r\n))\r\n\r\napp.get('/ssr', (req, res) => {\r\n  renderer.renderToString(\r\n    require(resolve(__dirname, './src/factory'))(),\r\n    (err, html) => {\r\n      if (err) {\r\n        console.error(err)\r\n        return res.status(500).send('Server error')\r\n      }\r\n      res.send(layout.replace('<div id=\"app\"></div>', html))\r\n    }\r\n  )\r\n})\r\n\r\napp.get('*', (req, res) => {\r\n  res.send(layout)\r\n})\r\n\r\napp.listen(process.env.PORT || 3000, () => console.log('Running :3000'))\r\n```\r\n\r\nI do not understand how to do it, as it should not be taking the factory.js from the raw code, but compiled."}}
{"actor":{"display_login":"vue-issue-bot"}}