Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for SSR use? #9

Open
DominicGebhart opened this issue Jan 21, 2019 · 1 comment
Open

Example for SSR use? #9

DominicGebhart opened this issue Jan 21, 2019 · 1 comment
Labels
question Further information is requested

Comments

@DominicGebhart
Copy link

Really great Example,

i also got it to work in my Nuxt.js Enviroment but without the SSR :(
I'm trying since Days to get it work in SSR mode. Could you provide some Information/Tipps or even a Example for that kind of case.

When i load it, i get the Error: 'document' not defined, because its server rendered.
As far as i found out is that it may be achivable with the target set to 'node'. In the packaged index.js i find some document uses from the vue-style-loader and and a line saying:
'vue-style-loader cannot be used in a non-browser environment. ' + "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."

But until now i didn't managed to set the target of the build

Any ideas? :)

@chrisvfritz
Copy link
Owner

The module build should automatically work with SSR, because it relies on the user for compilation and they can specify target: 'node' in their configuration.

The CJS and UMD builds are a different story though. Personally, I would just tell SSR users not to use them. However, if you wanted to assume an SSR context, then I believe adding config.target('node') to the chainWebpack function in vue.config.js should work. If you want to separate versions for SSR and the browser, then you'd probably want to use something like config.target(process.env.WEBPACK_TARGET) instead and then update build-lib.js create SSR builds.

Does that make sense?

@chrisvfritz chrisvfritz added the question Further information is requested label Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants