quill-image-resize-module: Cannot read property 'imports' of undefined Nuxtjs/SSR
Getting the following error when i am adding the module to Quill.
Uncaught TypeError: Cannot read property 'imports' of undefined
at Object.<anonymous> (app.508b1bdd306748193b03.js:9923)
at e (app.508b1bdd306748193b03.js:9923)
at Object.<anonymous> (app.508b1bdd306748193b03.js:9923)
at e (app.508b1bdd306748193b03.js:9923)
at app.508b1bdd306748193b03.js:9923
at app.508b1bdd306748193b03.js:9923
at webpackJsonp../node_modules/quill-image-resize-module/image-resize.min.js (app.508b1bdd306748193b03.js:9923)
at Object../node_modules/quill-image-resize-module/image-resize.min.js (app.508b1bdd306748193b03.js:9923)
at __webpack_require__ (manifest.2ea815068b6b951c57aa.js:713)
at fn (manifest.2ea815068b6b951c57aa.js:118)
~/plugins/nuxt-quill-plugin.js
import Vue from 'vue'
import Quill from 'quill'
import { ImageResize } from 'quill-image-resize-module'
if (process.browser) {
const VueQuillEditor = require('vue-quill-editor/ssr')
Quill.register('modules/imageResize', ImageResize)
Vue.use(VueQuillEditor)
}
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 7
- Comments: 21
@Temmermans
plugins: [ new webpack.ProvidePlugin({ ‘window.Quill’: ‘quill’ }) ]
https://github.com/kensnyder/quill-image-resize-module/issues/7
@Mrjianghan After i remove the brace, i get the following error in Browser Console.
@ggJSC
imports-loader
worked for me:Then you don’t have to register the module, just import it straight away:
This is due to https://github.com/kensnyder/quill-image-resize-module/blob/master/src/ImageResize.js#L198.
@iampawan31 I use spa,not ssr,sorry
The solution is based on @Mrjianghan’s answer (if a Quill module uses Webpack, you must expose the Quill instance as a Webpack plugin so that it can find it. Sadly, this was not documented anywhere).
I wrote up a more comprehensive solution, in hopes it helps others and submitted a pull request with a link to that solution for the main readme in vue-quill-editor: https://github.com/surmon-china/vue-quill-editor/issues/171#issuecomment-370253411
@Temmermans it’s working for `me,
my code
`import Quill from ‘quill’;
For Nuxt/SSR this solution helped https://github.com/surmon-china/vue-quill-editor/issues/171#issuecomment-370253411