ruhley / angular-color-picker

Vanilla AngularJS Color Picker Directive with no requirement on jQuery
http://ruhley.github.io/angular-color-picker/
MIT License
166 stars 79 forks source link

Require.js can't find "tinycolor2" #110

Closed TheWizz closed 8 years ago

TheWizz commented 8 years ago

When using RequreJS to load dependencies, loading the coloepicker, results in this error:

Error: Script error for "tinycolor2", needed by: angularColorPicker

I use Bower as the package manager, and under Bower it seems the package is called just "tinycolor", while it's called "tinycolor2" under npm.

How can I resolve this discrepancy so that the color picker loads "tinycolor" and doesn't complain about not finding "tinycolor2"?

-JM

ruhley commented 8 years ago

Hi @TheWizz,

I don't have any experience with RequireJS so I may not be much of a help. You can try looking into another ticket with a similar problem #66. You could also try configuring RequireJS to look for tinycolor2

requirejs.config({
       paths:
           tinycolor2: 'bower_components/angular-color-picker/dist/angular-color-picker.min'
       }
   });
TheWizz commented 8 years ago

Yes, I managed to load the "tinycolor2" version and apply it as a global like this:

require(['angular','tinycolor2','ngMaterial', 'uiRouterDefault'], function(angular, tinycolor) {
    window.tinycolor = tinycolor;   // Expected as global by colorPicker, loaded subsequently

Having it available through Require under the name 'tinycolor2' while also assigning it as a window global under the name tinycolor seemed to make everybody happy.

-JM