annotorious-v1 icon indicating copy to clipboard operation
annotorious-v1 copied to clipboard

Using with Vuejs webpack

Open ilijaveselica opened this issue 8 years ago • 4 comments

How to use this library with vue webpack? I've included the min.js file in main.js and getting the error:

annotorious.min.js?0dce:8 Uncaught TypeError: Cannot read property 'navigator' of undefined(…)

However, if I include it directly in html file then it works, but that's not the "proper" way to do it.

ilijaveselica avatar Jan 17 '17 16:01 ilijaveselica

Hi, I met the same problem. How did you solve it ? @ilijaveselica

gywgithub avatar May 31 '17 02:05 gywgithub

@gywgithub I didn't solve it. I made my own solution for this

ilijaveselica avatar May 31 '17 07:05 ilijaveselica

I solved this problem using the exports-loader and script-loader.

npm i -D exports-loader script-loader

Configure in webpack.base.conf.js

...
module: {
  loaders: [
    {
      test: require.resolve('../src/assets/js/annotorious.min.js'),
      loader: 'exports-loader?window.anno!script-loader'
    }
 ]
}
...

Modify in the .vue file

require("exports?window.anno!../../src/assets/js/annotorious.min.js");

This can

gywgithub avatar Jun 06 '17 01:06 gywgithub

I did do anything. It is works for me (Webpack + Vue).

import 'annotorious';
import 'annotorious/css/theme-dark/annotorious-dark.css';
import 'annotorious-selector-pack/src/fancy_box_selector.js';
export default {
    mounted() {
        anno.addPlugin('FancyBoxSelector', { activate: true });
    }
    methods: {
        init() {
            window.anno.makeAnnotatable(this.$refs.img);
        }
    }
}

for the template

<img src="THE_IMG_URL" @load="init" ref="img">

wuliupo avatar Jan 31 '19 15:01 wuliupo