oakmac / chessboard2

chessboard.js v2
ISC License
81 stars 7 forks source link

Importing chessboard2 #45

Open djeetee opened 1 year ago

djeetee commented 1 year ago

Hi Chris,

unless I'm doing something wrong, it would be great to be able to simply use the following:

import { Chessboard2 } from '@chrisoakman/chessboard2'

instead of this:

import { Chessboard2 } from '/node_modules/@chrisoakman/chessboard2/dist/chessboard2.min.mjs'

I have tried all kind of permutations in my Vue app and only the second option works.

btw, i have one hell of a time getting repl.it to import it.

I hope I'm missing something which is not unheard of ;)

thanks.

oakmac commented 1 year ago

I suspect this may have something to do with listing the .mjs module file inside package.json, but I am not 100% sure.

Ystalard commented 1 year ago

Hello @djeetee,

I am also struggling to import chessboard2 inside the component of my angular application. Woud you have some tips for me?

Thanks !

michalsgit commented 1 year ago

You can add reference to the css styles and javascript in angular.json in: projects/{ProjectName}/architect/build/options

set:

"styles": [
  "src/styles.scss",
  "node_modules/@chrisoakman/chessboard2/dist/chessboard2.min.css"
],
"scripts": [
  "node_modules/@chrisoakman/chessboard2/dist/chessboard2.min.js"
],

Then you can use it like this:

declare var Chessboard2: any;

...

Chessboard2('chessboardId',...)
Ystalard commented 1 year ago

Thanks I'll try this next week !

Le mar. 27 juin 2023, 06:57, Michal @.***> a écrit :

You can add reference to the css styles and javascript in angular.json in: projects/{ProjectName}/architect/build/options

set:

"styles": [ "src/styles.scss", @./chessboard2/dist/chessboard2.min.css" ],"scripts": [ @./chessboard2/dist/chessboard2.min.js" ],

Then you can use it like this:

(window as any).Chessboard2('chessboardId',...)

— Reply to this email directly, view it on GitHub https://github.com/oakmac/chessboard2/issues/45#issuecomment-1608797407, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN43Q52QAA5CZ36G2GQT2BLXNJR4RANCNFSM6AAAAAAXLXTAMM . You are receiving this because you commented.Message ID: @.***>