Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: can't write alias properly #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

camera-2018
Copy link

When I write config.vite.resolve.alias in withMermaid

export default withMermaid({
  vite: {
      resolve: {
        alias: [
          {
            find: /^.*\/VPSwitchAppearance\.vue$/,
            replacement: fileURLToPath(
              new URL('./components/CustomSwitchAppearance.vue', import.meta.url)
            )
          }
        ]
      }
    }
})

I've found they don't work. Because what I write will be turned into ☹

"0":{
  find: /^.*\/VPSwitchAppearance\.vue$/,
    replacement: fileURLToPath(
      new URL('./components/CustomSwitchAppearance.vue', import.meta.url)
  )
}

So I've tried to fix them

config.vite.resolve.alias = [
    ...config.vite.resolve.alias,
    {
      find: "dayjs/plugin/advancedFormat.js",
      replacement: "dayjs/esm/plugin/advancedFormat"
    },
    {
      find: "dayjs/plugin/customParseFormat.js",
      replacement: "dayjs/esm/plugin/customParseFormat"
    },
    {
      find: "dayjs/plugin/isoWeek.js",
      replacement: "dayjs/esm/plugin/isoWeek"
    },
    {
      find: "cytoscape/dist/cytoscape.umd.js",
      replacement: "cytoscape/dist/cytoscape.esm.js"
    },
  ];

But they haven't been tested much by me, so please review them carefully!

@emersonbottero
Copy link
Owner

The problem is that are several ways to pass the information..

resolve.alias
Type:Record<string, string> | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>
Will be passed to @rollup/plugin-alias as its entries option. Can either be an object, or an array of { find, replacement, customResolver } pairs.

I'll try to think of contemplating them all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants