biigpongsatorn / vue-element-loading

⏳ Loading inside a container or full screen for Vue.js
https://vue-element-loading.netlify.com/
MIT License
320 stars 31 forks source link

add ssr support #44

Open Sitronik opened 3 years ago

Sitronik commented 3 years ago

When I import vue-element-loading I get this error in ssr:

ReferenceError: document is not defined
    at /Users/denis/Documents/projects/project-ssr/node_modules/vue-element-loading/node_modules/vue-runtime-helpers/inject-style/browser.js:6:14
    at /Users/denis/Documents/projects/project-ssr/node_modules/vue-element-loading/lib/vue-element-loading.min.js:6:84
    at Object.<anonymous> (/Users/denis/Documents/projects/project-ssr/node_modules/vue-element-loading/lib/vue-element-loading.min.js:6:160)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Module._compile (/Users/denis/Documents/projects/project-ssr/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Object.newLoader [as .js] (/Users/denis/Documents/projects/project-ssr/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at r (/Users/denis/Documents/projects/project-ssr/node_modules/vue-server-renderer/build.dev.js:9315:16)
    at eval (webpack-internal:///vue-element-loading:1:18)
    at Object.vue-element-loading (main.js:1566:1)
    at __webpack_require__ (main.js:21:30)
    at eval (webpack-internal:///../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js?!./vue/blog/index.vue?vue&type=script&lang=js&:14:49)

And in client: 500 | Internal Server Error

Fixed it all, please merge

Sitronik commented 3 years ago

Hello @biigpongsatorn @runyasak, please merge this working changes.

runyasak commented 3 years ago

Hi, @Sitronik. Sorry for lately response.

Thank you for amazing PR. However, there have some errors on build. Please, resolve the errors and update to this PR. 😁

Sitronik commented 3 years ago

Hi, @Sitronik. Sorry for lately response.

Thank you for amazing PR. However, there have some errors on build. Please, resolve the errors and update to this PR. 😁

Hi, your are welcome Build is works but in deploy app netlify have errors

I changed billi to rollup. You can download this code Then run and you will see everything works correctly

Sitronik commented 3 years ago

Hi, @runyasak

The errors were due to the uglifyjs library. We need to come up with an alternative variant of minimizing the library

Sitronik commented 3 years ago

Fixed build netlify with rollup-plugin-uglify. Please @biigpongsatorn @runyasak, merge and publish 😁