anthonygore / vue-js-laravel-multi-ssr

Source code for the article "Advanced Server-Side Rendering With Laravel & Vue: Multi-Page App"
https://vuejsdevelopers.com/2017/11/27/vue-js-laravel-server-side-rendering-router/
37 stars 6 forks source link

Style Tags Are Breaking SSR #3

Closed pet1330 closed 6 years ago

pet1330 commented 6 years ago

Hi,

I was reading the related article, it has really helped! I've managed to get a project working, but am having an issue with the style tags not working.

Whenever you add a <style> section to a Vue component that you are trying to SSR, the render function in AppController returns undefined. Using your repository, I added empty style tags

<style>
</style>

to the bottom of your resource/assets/js/components/App.vue file and now it will only return undefined.

Do you have any idea why this might be happening or how to fix it?

anthonygore commented 6 years ago

Have you looked into the Laravel Mix docs? If the render function is returning undefined my guess is that there was a problem in the webpack build phase

KitaXvost commented 4 years ago

I have the same problem

I connect the webpack.config.js file to the root of the laravel project from the SSR-manual:

const ExtractTextPlugin = require('extract-text-webpack-plugin')
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {

          extractCSS: isProduction
        }
      },
         ]
  },
  plugins: isProduction

    ? [new ExtractTextPlugin({ filename: 'common.[chunkhash].css' })]
    : []
}

but there is no result