require('path') // αʔόαΠυͰར༻͢ΔͨΊɺάϩʔόϧมʹ Vue Λ ఆٛ͢Δ global.Vue = require('vue') var layout = fs.readFileSync('./index.html', 'utf8') var renderer = require('vue-server- renderer').createRenderer() var express = require('express') var server = express() // assets σΟϨΫτϦ੩తʹϑΝΠϧΛసૹ͢Δɻ server.use('/assets', express.static( path.resolve(__dirname, 'assets') )) server.get('/', function (request, response) { renderer.renderToString( require('./assets/app')(), function (error, html) { response.send(layout.replace('<div id="app"></div>', html)) } ) })
// 5000൪ϙʔτͰػ server.listen(5000, function (error) { if (error) throw error console.log('Server is running at localhost: 5000') }) SFOEFSFS FYQSFTTΠϯελϯεΛੜ