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

Vite config base and experimental is all not work #9700

Closed
1 task
peng opened this issue Jan 15, 2024 · 7 comments
Closed
1 task

Vite config base and experimental is all not work #9700

peng opened this issue Jan 15, 2024 · 7 comments
Labels
needs triage Issue needs to be triaged

Comments

@peng
Copy link
Contributor

peng commented Jan 15, 2024

Astro Info

Astro                    v4.0.8
Node                     v18.18.1
System                   macOS (arm64)
Package Manager          yarn
Output                   hybrid
Adapter                  @astrojs/node
Integrations             @astrojs/react
                         @astrojs/vue

If this issue only occurs in one browser, which browser is a problem?

build

Describe the Bug

It possible not a bug.

I want to config two cdn url, js file is https://a.com/static prefix url, css file is https://b.com/static prefix url. I found vite has renderBuiltUrl mehthod.

import { defineConfig } from 'astro/config';

const config = {
  vite: {
    experimental: {
      renderBuiltUrl(filename, { hostType }) {
            return 'https://a.com/static'
      }
    }
  }
}

export default defineConfig(config);

But vite.experimental.renderBuiltUrl is not work.

Is support vite.experimental.renderBuiltUrl config ?

What's the expected result?

Js, css, ... file can use different cdn url

Link to Minimal Reproducible Example

https://github.com/peng/astro-demo/

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 15, 2024
@ematipico ematipico added needs repro Issue needs a reproduction and removed needs triage Issue needs to be triaged labels Jan 15, 2024
Copy link
Contributor

Hello @peng. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@ematipico
Copy link
Member

It's possible that Astro's version of vite is outdated and doesn't have that option. Make sure you are using the correct version of vite.

@peng
Copy link
Contributor Author

peng commented Jan 16, 2024

vite/5.0.10 darwin-arm64 node-v18.18.1, but vite base options is not work either. I fount vite add experimental.renderBuiltUrl at 3.0.0 (2022-07-13). And demo repro: https://github.com/peng/astro-demo/

It's possible that Astro's version of vite is outdated and doesn't have that option. Make sure you are using the correct version of vite.

@ematipico ematipico added needs triage Issue needs to be triaged and removed needs repro Issue needs a reproduction labels Jan 16, 2024
@bluwy
Copy link
Member

bluwy commented Jan 16, 2024

In what way does it not work? I guess the feature does work partially, but it's not taking effect on all files that you expected, hence it isn't working well. Astro also uses that config internally (but you can override it) with its assetsPrefix option, but it's opinionated that it applies to both JS and CSS files. But that option should also cover cases where it would fail if you only used renderBuiltUrl yourself.

@peng
Copy link
Contributor Author

peng commented Jan 17, 2024

In what way does it not work? I guess the feature does work partially, but it's not taking effect on all files that you expected, hence it isn't working well. Astro also uses that config internally (but you can override it) with its assetsPrefix option, but it's opinionated that it applies to both JS and CSS files. But that option should also cover cases where it would fail if you only used renderBuiltUrl yourself.

Is vite.experimental.renderBuiltUrl can replace build.assetsPrefix config ? I think is not. So if I want use different cdn with js, css file. There is no configuration to support ?

@bluwy
Copy link
Member

bluwy commented Jan 17, 2024

Yeah there is not support for this. Astro only supports the prefix for both JS and CSS, and you can't choose between it. If you want to see support for it, you can open a discussion in https://github.com/withastro/roadmap. Closing this for now as it's not a bug.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2024
@peng
Copy link
Contributor Author

peng commented Jan 24, 2024

Yeah there is not support for this. Astro only supports the prefix for both JS and CSS, and you can't choose between it. If you want to see support for it, you can open a discussion in https://github.com/withastro/roadmap. Closing this for now as it's not a bug.
Ok, I have opened a discussion. And I want open a PR to reslove it.
Discussion: withastro/roadmap#818.

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

No branches or pull requests

3 participants