jgraph/mxgraph

npm package (latest version 4.2.0) factory method mxBasePath param not working

hungtcs opened this issue · 11 comments

the follow code to load mxgraph, but mxBasePath not working:

import factory from 'mxgraph';
const mx = factory({
      mxBasePath: 'assets',
});

image

if set window.mxBasePath = 'assets' is working well.

this demo can reappear the issues: https://stackblitz.com/edit/js-yjyqmw


version: 4.2.0

文件路径在public下开始查找的

您好 @LittleBoBo-beep,通过factory配置mxBasePath之后前缀应该生效的,但是这里没有,如果通过window.mxBasePath配置可以生效

看报错信息是build文件,你可以把mxgraph静态文件放置到根目录下的public或者static文件下,之后mxBasePath属性值改为./public或者./static即可

@LittleBoBo-beep 您好,我的意思是通过factory方法配置mxBasePath不生效

import mx from 'mxgraph'
const mxgraph = mx({
mxBasePath: './mxgraph'
})
这是我使用的

import mx from 'mxgraph'
const mxgraph = mx({
mxBasePath: './mxgraph'
})
这是我使用的

您那里mxBasePath生效了么?

生效了,你的不生效主要是mxGraph的静态资源存放位置不对

看报错信息是build文件,你可以把mxgraph静态文件放置到根目录下的public或者static文件下,之后mxBasePath属性值改为./public或者./static即可

mxBasePath就是用来配置资源路径的,你这里放到public或者static下,mxGraph默认就是从根目录下获取资源,所以你这里配不配mxBasePath没什么关系,如果你遇到了和我一样的问题,那么你的mxBasePath这里随便配什么路径都没有影响的,所以还是没生效,

https://stackblitz.com/edit/js-yjyqmw

你的静态资源放在什么路径下

@hungtcs @LittleBoBo-beep could you please provide a summary of your conversion in english for non-chinese speaking people 😸 ?
The issue you are describing seems close to #49
This is probably why this commonjs wrapper includes setting globals to the window object as workaround: https://github.com/asual/mxgraph-factory/blob/7dfe46b3d6634c5b6fcc4965be939c6547266409/src/mxgraph-factory.ts

Hi @tbouffard! Sorry for the unintelligible discussion, here are no substantive progress in the above discussion.
I have been trying to explain to @LittleBoBo-beep the assets location path is not related to this issues.